package com.ixuestar.service.impl;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.transaction.Transactional;

import org.apache.log4j.Logger;
import org.jodconverter.DocumentConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.itextpdf.text.pdf.PdfReader;
import com.ixuestar.dao.IxuestarCloudELMapper;
import com.ixuestar.entity.Advertisingassoc;
import com.ixuestar.entity.Advertisingitems;
import com.ixuestar.entity.Advertisingschool;
import com.ixuestar.entity.BankcardInfo;
import com.ixuestar.entity.Classbean;
import com.ixuestar.entity.ClassbeanRecord;
import com.ixuestar.entity.Integraltype;
import com.ixuestar.entity.IssueclassFile;
import com.ixuestar.entity.Issueclassnotice;
import com.ixuestar.entity.PictureInfo;
import com.ixuestar.entity.ProbabilityEntity;
import com.ixuestar.entity.Replytoclassfile;
import com.ixuestar.entity.Replytoclassnotice;
import com.ixuestar.entity.School;
import com.ixuestar.entity.SchoolClass;
import com.ixuestar.entity.SchoolGrade;
import com.ixuestar.entity.SchoolStudent;
import com.ixuestar.entity.SchoolTeacher;
import com.ixuestar.entity.Subject;
import com.ixuestar.entity.TeacherBeanRecord;
import com.ixuestar.entity.Temp;
import com.ixuestar.entity.WechatConfig;
import com.ixuestar.entity.WithdrawalOrder;
import com.ixuestar.entity.YxAdvertising;
import com.ixuestar.entity.YxArticlesComment;
import com.ixuestar.entity.YxArticlesOtherInfo;
import com.ixuestar.entity.YxChecknotice;
import com.ixuestar.entity.YxClassClockin;
import com.ixuestar.entity.YxClassschedule;
import com.ixuestar.entity.YxEduArticles;
import com.ixuestar.entity.YxEquipment;
import com.ixuestar.entity.YxExamination;
import com.ixuestar.entity.YxFile;
import com.ixuestar.entity.YxHeadTeacher;
import com.ixuestar.entity.YxHeadtPoints;
import com.ixuestar.entity.YxIcnClass;
import com.ixuestar.entity.YxLotteryInfo;
import com.ixuestar.entity.YxLotteryPrize;
import com.ixuestar.entity.YxLotteryRecord;
import com.ixuestar.entity.YxLotterySchool;
import com.ixuestar.entity.YxMalfunction;
import com.ixuestar.entity.YxOrderClass;
import com.ixuestar.entity.YxOrderFile;
import com.ixuestar.entity.YxOrderPackage;
import com.ixuestar.entity.YxPoints;
import com.ixuestar.entity.YxPrizeInfo;
import com.ixuestar.entity.YxPromotionCode;
import com.ixuestar.entity.YxSubject;
import com.ixuestar.entity.YxTeacherClass;
import com.ixuestar.entity.YxTeacherSubject;
import com.ixuestar.entity.YxWatchAds;
import com.ixuestar.entity.YxWeeksClass;
import com.ixuestar.entity.YxWxuser;
import com.ixuestar.entity.YxWxuserCode;
import com.ixuestar.entity.YxWxuserOrder;
import com.ixuestar.entity.Yxintegralrecord;
import com.ixuestar.entity.YxteacherBean;
import com.ixuestar.entity.Yxtestscores;
import com.ixuestar.entity.Yxtorder;
import com.ixuestar.entity.YxuserLottery;
import com.ixuestar.service.IxuestarCloudELService;
import com.ixuestar.util.CommonUtil;
import com.ixuestar.util.ConvertToPdf;
import com.ixuestar.util.DateUtil;
import com.ixuestar.util.FileControl;
import com.ixuestar.util.MailUtil;
import com.ixuestar.util.MessageUtil;
import com.ixuestar.util.MyAlgorithmUtil;
import com.ixuestar.util.QiniuUpLoad;
import com.ixuestar.util.WorkDayCalculateUtils;
import com.ixuestar.websocket.WebSocketController;
import com.ixuestar.wxutil.GetwxOpenId;
import com.ixuestar.wxutil.PayConfigUtil;
@Transactional
@Service("/ixuestarCloudELService")
public class IxuestarCloudELServiceImpl implements IxuestarCloudELService {

	@Autowired
	private IxuestarCloudELMapper ixuestarCloudELMapper;
	
	private Logger logger = Logger.getLogger(IxuestarCloudELServiceImpl.class);
	//创建documentConverter
	private static DocumentConverter documentConverter;
	
	@Override
	public JSONObject getWxSessionKey(String code) {
		// TODO Auto-generated method stub
		int co = 0;
		JSONObject resultObject = new JSONObject();
		String appId = PayConfigUtil.ixuestarwx_APP_ID_CloudTeacher;
		String appSec = PayConfigUtil.ixuestarwx_APP_SEC_CloudTeacher;
		//获取
		try {
			JSONObject wxSessionKey = GetwxOpenId.getWxSessionKey(code,appId,appSec);
			resultObject.putAll(wxSessionKey);
			//获取openid
			String openid = wxSessionKey.getString("openid");
			//获取是否存在
			//1 数据库中是否存在老师的手机号信息
			Map<String, Object> hashMap = new HashMap<>();
			hashMap.put("lineKey", "ywOpenId");
			hashMap.put("lineValue", openid);
			YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
			if (yxWxuser==null) {
				co = 1;
			}else {
				resultObject.putAll((JSONObject)JSONObject.toJSON(yxWxuser));
				String ixssId = yxWxuser.getIxssId();
				if (ixssId==null || ixssId.trim().equals("")) {
					co = 2;
				}else {
					//获取老师的姓名和其他信息
					hashMap.put("lineKey", "ixstId");
					hashMap.put("lineValue", ixssId);
					//获取老师所教的班级
					JSONArray jsonArray = new JSONArray();
					Set<Object> hashSet = new HashSet<>();
					List<YxTeacherClass> teacherClasses = ixuestarCloudELMapper.getTeacherClasses(hashMap);
					logger.info("-----teacherClasses-"+teacherClasses+"--------");
					for (int i = 0; i < teacherClasses.size(); i++) {
						JSONObject teacherObject = new JSONObject();
						YxTeacherClass yxTeacherClass = teacherClasses.get(i);
						String ixscId = yxTeacherClass.getIxscId();
						hashMap.put("lineKey", "ixscId");
						hashMap.put("lineValue", ixscId);
						//班级
						SchoolClass schoolClass = ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0);
						logger.info("-----schoolClass-"+schoolClass+"--------");
						if (schoolClass!=null) {
							String ixscName = schoolClass.getIxscName();
							teacherObject.put("ixscId", ixscId);
							teacherObject.put("ixscName", ixscName);
							//获取班级豆
							Classbean classbeanInfo = ixuestarCloudELMapper.getClassbeanInfo(ixscId);
							Integer classbean = classbeanInfo==null?0:classbeanInfo.getYcbNumber();
							teacherObject.put("classbean", classbean);
									
							String ixsgId = schoolClass.getIxsgId();
							hashSet.add(ixsgId);
							//获取年级信息
							hashMap.put("lineKey", "ixsgId");
							hashMap.put("lineValue", ixsgId);
							SchoolGrade schoolGrade = ixuestarCloudELMapper.getSchoolGrades(hashMap).get(0);
							if (schoolGrade!=null) {
								String ixsId = schoolGrade.getIxsId();
								String ixsgName = schoolGrade.getIxsgName();
								//年级
								teacherObject.put("ixsgId", ixsgId);
								teacherObject.put("ixsgName", ixsgName);
								hashMap.put("flag", 1);
								hashMap.put("lineKey", "ixsId");
								hashMap.put("lineValue", ixsId);
								School school = ixuestarCloudELMapper.getSchoolInfo(hashMap).get(0);
								logger.info("-----school-"+school+"--------");
								if (school!=null) {
									int ixsType = school.getIxsType();
									String ixsName = school.getIxsName();
									teacherObject.put("ixsId", ixsId);
									teacherObject.put("ixsType", ixsType);
									teacherObject.put("ixsName", ixsName);
								}
							}
							jsonArray.add(teacherObject);
						}
					}
					resultObject.put("teacherClass", jsonArray);
					//获取年级班级
					JSONArray gradeArray = new JSONArray();
					Iterator<Object> iterator = hashSet.iterator();
					while (iterator.hasNext()) {
						JSONObject gradeObject = new JSONObject();
						String ixsgId = iterator.next().toString();
						hashMap.put("lineKey", "ixsgId");
						hashMap.put("lineValue", ixsgId);
						String ixsgName = ixuestarCloudELMapper.getSchoolGrades(hashMap).get(0).getIxsgName();
						//获取班级列表
						List<SchoolClass> classList = ixuestarCloudELMapper.getSchoolClasses(hashMap);
						gradeObject.put("ixsgId", ixsgId);
						gradeObject.put("ixsgName", ixsgName);
						gradeObject.put("classList", classList);
						gradeArray.add(gradeObject);
					}
					resultObject.put("gradeClass", gradeArray);
					//获取所教科目
					hashMap.put("lineKey", "ixstId");
					hashMap.put("lineValue", ixssId);
					JSONArray teacherSubjectArray = new JSONArray();
					List<YxTeacherSubject> teacherSubjects = ixuestarCloudELMapper.getTeacherSubjects(hashMap);
					logger.info("-----teacherSubjects-"+teacherSubjects+"--------");
					for (int i = 0; i < teacherSubjects.size(); i++) {
						JSONObject teacherSubjectObject = new JSONObject();
						YxTeacherSubject yxTeacherSubject = teacherSubjects.get(i);
						String ixsId = yxTeacherSubject.getIxsId();
						hashMap.put("lineKey", "ixsId");
						hashMap.put("lineValue", ixsId);
						Subject subjectInfo = ixuestarCloudELMapper.getSubjectInfo(hashMap);
						logger.info("-----subjectInfo-"+subjectInfo+"--------");
						if (subjectInfo!=null) {
							String ixsName = subjectInfo.getIxsName();
							teacherSubjectObject.put("ixsId", ixsId);
							teacherSubjectObject.put("ixsName", ixsName);
							teacherSubjectArray.add(teacherSubjectObject);
						}
					}
					resultObject.put("teacherSubject", teacherSubjectArray);
					//获取班主任的积分
					JSONObject headtPObject = new JSONObject();
					hashMap.put("lineKey", "ixstId");
					hashMap.put("lineValue", ixssId);
					YxHeadTeacher yxHeadTeacherInfo = ixuestarCloudELMapper.getYxHeadTeacherInfo(hashMap);
					if (yxHeadTeacherInfo!=null) {
						String ixscId = yxHeadTeacherInfo.getIxscId();
						YxHeadtPoints headtPoints = ixuestarCloudELMapper.getHeadtPoints(ixssId);
						if (headtPoints!=null) {
							Integer yhtpoints = headtPoints.getYhtpoints();
							headtPObject.put("yhtpoints", yhtpoints);
						}else {
							headtPObject.put("yhtpoints", 0);
						}
						headtPObject.put("ixscId", ixscId);
						headtPObject.put("headTeacher", 1);
					}else {
						YxHeadtPoints headtPoints = ixuestarCloudELMapper.getHeadtPoints(ixssId);
						if (headtPoints==null) {
							headtPObject.put("yhtpoints", 0);							
						}else {
							Integer yhtpoints = headtPoints.getYhtpoints();
							headtPObject.put("yhtpoints", yhtpoints);
						}
						headtPObject.put("ixscId", null);
						headtPObject.put("headTeacher", 0);
					}
					resultObject.put("headTeacher", headtPObject);
					hashMap.put("lineKey", "ixstId");
					hashMap.put("lineValue", ixssId);
					SchoolTeacher schoolTeacher = ixuestarCloudELMapper.getSchoolTeachers(hashMap).get(0);
					logger.info("-----schoolTeacher-"+schoolTeacher+"--------");
					if (schoolTeacher!=null) {
						String ixstName = schoolTeacher.getIxstName();
						resultObject.put("ixstName", ixstName);
					}
					//获取老师的打印豆
					YxteacherBean yxteacherBeanInfo = ixuestarCloudELMapper.getYxteacherBeanInfo(ixssId);
					Integer teacherbean = yxteacherBeanInfo==null?0:yxteacherBeanInfo.getYtbNumber();
					resultObject.put("teacherBean", teacherbean);
				}
			}
			resultObject.put("code", co);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return resultObject;
	}
	
	@Override
	public JSONObject getWxuserInfo(JSONObject jsonObject) {
		// TODO Auto-generated method stub
		//通过获取的手机号进行判断
		int code = 0;
		JSONObject yxuserObject = new JSONObject();
		//解析老师手机号
		String wxIv = jsonObject.getString("wxIv");
		String openId = jsonObject.getString("openId");
		String wxSessionKey = jsonObject.getString("wxSessionKey");
		String encryptedData = jsonObject.getString("encryptedData");
		//执行接口
		final JSONObject wxTelephone = GetwxOpenId.getWxTelephone(encryptedData, wxSessionKey, wxIv);
		if (wxTelephone.isEmpty()) {
			//解析手机号失败
			code = -1;
		}else {
			//获取手机号
			String phoneNumber = wxTelephone.getString("phoneNumber");
			//1 数据库中是否存在老师的手机号信息
			Map<String, Object> hashMap = new HashMap<>();
			hashMap.put("lineKey", "ywOpenId");
			hashMap.put("lineValue", openId);
			YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
			logger.info("-----yxWxuser-"+yxWxuser+"--------");
			//1.1 如果存在 查询是否绑定
			if (yxWxuser!=null) {
				String ixssId = yxWxuser.getIxssId();
				JSONObject yxWxuserObject = (JSONObject)JSONObject.toJSON(yxWxuser);
				//1.1.1如果已经绑定，则返回老师绑定的基本信息
				if (ixssId!=null) {
					//获取老师的姓名和其他信息
					hashMap.put("lineKey", "ixstId");
					hashMap.put("lineValue", ixssId);
					//获取老师所教的班级
					JSONArray jsonArray = new JSONArray();
					Set<Object> hashSet = new HashSet<>();
					List<YxTeacherClass> teacherClasses = ixuestarCloudELMapper.getTeacherClasses(hashMap);
					logger.info("-----teacherClasses-"+teacherClasses+"--------");
					for (int i = 0; i < teacherClasses.size(); i++) {
						JSONObject teacherObject = new JSONObject();
						YxTeacherClass yxTeacherClass = teacherClasses.get(i);
						String ixscId = yxTeacherClass.getIxscId();
						hashMap.put("lineKey", "ixscId");
						hashMap.put("lineValue", ixscId);
						//班级
						SchoolClass schoolClass = ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0);
						logger.info("-----schoolClass-"+schoolClass+"--------");
						if (schoolClass!=null) {
							String ixscName = schoolClass.getIxscName();
							teacherObject.put("ixscId", ixscId);
							teacherObject.put("ixscName", ixscName);
							//获取班级豆
							Classbean classbeanInfo = ixuestarCloudELMapper.getClassbeanInfo(ixscId);
							Integer classbean = classbeanInfo==null?0:classbeanInfo.getYcbNumber();
							teacherObject.put("classbean", classbean);
							
							String ixsgId = schoolClass.getIxsgId();
							hashSet.add(ixsgId);
							//获取年级信息
							hashMap.put("lineKey", "ixsgId");
							hashMap.put("lineValue", ixsgId);
							SchoolGrade schoolGrade = ixuestarCloudELMapper.getSchoolGrades(hashMap).get(0);
							if (schoolGrade!=null) {
								String ixsId = schoolGrade.getIxsId();
								String ixsgName = schoolGrade.getIxsgName();
								//年级
								teacherObject.put("ixsgId", ixsgId);
								teacherObject.put("ixsgName", ixsgName);
								hashMap.put("flag", 1);
								hashMap.put("lineKey", "ixsId");
								hashMap.put("lineValue", ixsId);
								School school = ixuestarCloudELMapper.getSchoolInfo(hashMap).get(0);
								logger.info("-----school-"+school+"--------");
								if (school!=null) {
									String ixsName = school.getIxsName();
									int ixsType = school.getIxsType();
									
									teacherObject.put("ixsId", ixsId);
									teacherObject.put("ixsType", ixsType);
									teacherObject.put("ixsName", ixsName);
								}
							}
							jsonArray.add(teacherObject);
						}
					}
					yxWxuserObject.put("teacherClass", jsonArray);
					//获取年级班级
					JSONArray gradeArray = new JSONArray();
					Iterator<Object> iterator = hashSet.iterator();
					while (iterator.hasNext()) {
						JSONObject gradeObject = new JSONObject();
						String ixsgId = iterator.next().toString();
						hashMap.put("lineKey", "ixsgId");
						hashMap.put("lineValue", ixsgId);
						String ixsgName = ixuestarCloudELMapper.getSchoolGrades(hashMap).get(0).getIxsgName();
						//获取班级列表
						List<SchoolClass> classList = ixuestarCloudELMapper.getSchoolClasses(hashMap);
						gradeObject.put("ixsgId", ixsgId);
						gradeObject.put("ixsgName", ixsgName);
						gradeObject.put("classList", classList);
						gradeArray.add(gradeObject);
					}
					yxWxuserObject.put("gradeClass", gradeArray);
					//获取所教科目
					hashMap.put("lineKey", "ixstId");
					hashMap.put("lineValue", ixssId);
					JSONArray teacherSubjectArray = new JSONArray();
					List<YxTeacherSubject> teacherSubjects = ixuestarCloudELMapper.getTeacherSubjects(hashMap);
					logger.info("-----teacherSubjects-"+teacherSubjects+"--------");
					for (int i = 0; i < teacherSubjects.size(); i++) {
						JSONObject teacherSubjectObject = new JSONObject();
						YxTeacherSubject yxTeacherSubject = teacherSubjects.get(i);
						String ixsId = yxTeacherSubject.getIxsId();
						hashMap.put("lineKey", "ixsId");
						hashMap.put("lineValue", ixsId);
						Subject subjectInfo = ixuestarCloudELMapper.getSubjectInfo(hashMap);
						logger.info("-----subjectInfo-"+subjectInfo+"--------");
						if (subjectInfo!=null) {
							String ixsName = subjectInfo.getIxsName();
							teacherSubjectObject.put("ixsId", ixsId);
							teacherSubjectObject.put("ixsName", ixsName);
							teacherSubjectArray.add(teacherSubjectObject);
						}
					}
					yxWxuserObject.put("teacherSubject", teacherSubjectArray);
					//获取班主任的积分
					JSONObject headtPObject = new JSONObject();
					hashMap.put("lineKey", "ixstId");
					hashMap.put("lineValue", ixssId);
					YxHeadTeacher yxHeadTeacherInfo = ixuestarCloudELMapper.getYxHeadTeacherInfo(hashMap);
					if (yxHeadTeacherInfo!=null) {
						String ixscId = yxHeadTeacherInfo.getIxscId();
						YxHeadtPoints headtPoints = ixuestarCloudELMapper.getHeadtPoints(ixssId);
						if (headtPoints!=null) {
							Integer yhtpoints = headtPoints.getYhtpoints();
							headtPObject.put("yhtpoints", yhtpoints);
						}else {
							headtPObject.put("yhtpoints", 0);
						}
						headtPObject.put("ixscId", ixscId);
						headtPObject.put("headTeacher", 1);
					}else {
						YxHeadtPoints headtPoints = ixuestarCloudELMapper.getHeadtPoints(ixssId);
						if (headtPoints==null) {
							headtPObject.put("yhtpoints", 0);							
						}else {
							Integer yhtpoints = headtPoints.getYhtpoints();
							headtPObject.put("yhtpoints", yhtpoints);
						}
						headtPObject.put("ixscId", null);
						headtPObject.put("headTeacher", 0);
					}
					yxuserObject.put("headTeacher", headtPObject);
					hashMap.put("lineKey", "ixstId");
					hashMap.put("lineValue", ixssId);
					SchoolTeacher schoolTeacher = ixuestarCloudELMapper.getSchoolTeachers(hashMap).get(0);
					logger.info("-----schoolTeacher-"+schoolTeacher+"--------");
					if (schoolTeacher!=null) {
						String ixstName = schoolTeacher.getIxstName();
						yxWxuserObject.put("ixstName", ixstName);
					}
					//获取老师的打印豆
					YxteacherBean yxteacherBeanInfo = ixuestarCloudELMapper.getYxteacherBeanInfo(ixssId);
					Integer teacherbean = yxteacherBeanInfo==null?0:yxteacherBeanInfo.getYtbNumber();
					yxWxuserObject.put("teacherBean", teacherbean);
				}else {
					//1.1.2如果没有绑定，则返回让老师绑定代码  http://59.110.221.128:8088/ixuestarSmartTerminal/index.html#/homePage?mchnId=MA00000003
					code = 1;
					JSONObject headtPObject = new JSONObject();
					headtPObject.put("yhtpoints", 0);
					headtPObject.put("ixscId", null);
					headtPObject.put("headTeacher", 0);
					yxuserObject.put("headTeacher", headtPObject);
				}
				yxuserObject.putAll(yxWxuserObject);
			}else {
				String ywImgUrl = "https://cdn.travbao.com/WechatIMG73.png";
				//1.2 如果不存在 则插入信息 并返回让老师绑定代码
				YxWxuser yxWxuser2 = new YxWxuser();
				//创建ywId
				String ywId = "yw" + new Date().getTime() + (int)(Math.random()*10);
				//创建时间
				String ywCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
				yxWxuser2.setYwId(ywId);
				yxWxuser2.setYwOpenId(openId);
				yxWxuser2.setYwImgUrl(ywImgUrl);
				yxWxuser2.setYwTelephone(phoneNumber);
				yxWxuser2.setYwCreatetime(ywCreatetime);
				yxWxuser2.setYwType("1");
				yxWxuser2.setIxssId(null);
				ixuestarCloudELMapper.writeYxWxuser(yxWxuser2);
				yxuserObject.putAll((JSONObject)JSONObject.toJSON(yxWxuser2));
				code = 2;
				JSONObject headtPObject = new JSONObject();
				headtPObject.put("yhtpoints", 0);
				headtPObject.put("ixscId", null);
				headtPObject.put("headTeacher", 0);
				yxuserObject.put("headTeacher", headtPObject);
			}
			
		}
		yxuserObject.put("code", code);
		return yxuserObject;
	}

	@Override
	public JSONObject getSchoolInfos(JSONObject jsonObject) {
		// TODO Auto-generated method stub
		JSONObject schoolObject = new JSONObject();
		//首先获取参数
		int ixsType = jsonObject.getInteger("ixsType");
		//根据参数获取复核条件的学校列表
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("flag", 1);
		hashMap.put("lineKey", "ixsType");
		hashMap.put("lineValue", ixsType);
		List<School> schoolInfo = ixuestarCloudELMapper.getSchoolInfo(hashMap);
		logger.info("----------"+schoolInfo.size()+"---------");
		if (schoolInfo.size()!=0) {
			schoolObject.put("schoolList", schoolInfo);
			schoolObject.put("schoolNum", schoolInfo.size());
		}
		return schoolObject;
	}

	@Override
	public JSONObject getSchoolGradeList(JSONObject jsonObject) {
		// TODO Auto-generated method stub
		JSONObject gradeclassObject = new JSONObject();
		JSONArray gradeclassArray = new JSONArray();
		//通过获取的参数 获取学校下的年级列表
		String ixsId = jsonObject.getString("ixsId");
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ixsId");
		hashMap.put("lineValue", ixsId);
		List<SchoolGrade> schoolGrades = ixuestarCloudELMapper.getSchoolGrades(hashMap);
		for (int i = 0; i < schoolGrades.size(); i++) {
			JSONObject gradeObject = new JSONObject();
			//获取年级对象
			SchoolGrade schoolGrade = schoolGrades.get(i);
			String ixsgId = schoolGrade.getIxsgId();
			gradeObject.put("ixsgId", ixsgId);
			String ixsgName = schoolGrade.getIxsgName();
			gradeObject.put("ixsgName", ixsgName);
			//获取年级对应的班级
			hashMap.put("lineKey", "ixsgId");
			hashMap.put("lineValue", ixsgId);
			List<SchoolClass> schoolClasses = ixuestarCloudELMapper.getSchoolClasses(hashMap);
			gradeObject.put("schoolClasses", schoolClasses);
			gradeclassArray.add(gradeObject);
		}
		gradeclassObject.put("schoolGradeList", gradeclassArray);
		gradeclassObject.put("schoolGradeNum", gradeclassArray.size());
		return gradeclassObject;
	}

	@Override
	public JSONObject getSchoolClassList(JSONObject jsonObject) {
		// TODO Auto-generated method stub
		JSONObject classObject = new JSONObject();
		//通过获取的参数 获取年级下的班级列表
		String ixsgId = jsonObject.getString("ixsgId");
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ixsgId");
		hashMap.put("lineValue", ixsgId);
		List<SchoolClass> schoolClasses = ixuestarCloudELMapper.getSchoolClasses(hashMap);
		if (!schoolClasses.isEmpty()) {
			classObject.put("schoolClassList", schoolClasses);
			classObject.put("schoolClassNum", schoolClasses.size());
		}
		return classObject;
	}
	
	@Override
	public JSONObject getSchoolTeacherList(JSONObject jsonObject) {
		// TODO Auto-generated method stub
		JSONObject teacherObject = new JSONObject();
		JSONArray teacherArray = new JSONArray();
		//获取科目id
		String ixsId = jsonObject.getString("ixsId");
		String ixshId = jsonObject.getString("ixshId");
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("ixsId", ixsId);
		hashMap.put("ixshId", ixshId);
		List<YxTeacherSubject> teacherSubjects = ixuestarCloudELMapper.getTeacherSubInfo(hashMap);
		for (int i = 0; i < teacherSubjects.size(); i++) {
			YxTeacherSubject yxTeacherSubject = teacherSubjects.get(i);
			String ixstId = yxTeacherSubject.getIxstId();
			hashMap.put("lineKey", "ixstId");
			hashMap.put("lineValue", ixstId);
			SchoolTeacher schoolTeacher = ixuestarCloudELMapper.getSchoolTeachers(hashMap).get(0);
			if (schoolTeacher!=null) {
				JSONObject teaObject = new JSONObject();
				String ixstName = schoolTeacher.getIxstName();
				teaObject.put("ixstId", ixstId);
				teaObject.put("ixstName", ixstName);
				teacherArray.add(teaObject);
			}
		}
		//返回参数
		teacherObject.put("teacherList", teacherArray);
		teacherObject.put("teacherNum", teacherArray.size());
		//获取信息
		return teacherObject;
	}
	
	@Override
	public JSONObject getTeacherInfo(JSONObject jsonObject) {
		// TODO Auto-generated method stub
		JSONObject teacherObject = new JSONObject();
		JSONArray teacherArray = new JSONArray();
		//获取老师信息id
		String ixstId = jsonObject.getString("ixstId");
		//获取所在班级年级
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ixstId");
		hashMap.put("lineValue", ixstId);
		List<YxTeacherClass> teacherClasses = ixuestarCloudELMapper.getTeacherClasses(hashMap);
		logger.info("------teacherClasses-"+teacherClasses+"--------");
		for (int i = 0; i < teacherClasses.size(); i++) {
			YxTeacherClass yxTeacherClass = teacherClasses.get(i);
			String ixscId = yxTeacherClass.getIxscId();
			hashMap.put("lineKey", "ixscId");
			hashMap.put("lineValue", ixscId);
			SchoolClass schoolClass = ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0);
			if (schoolClass!=null) {
				String ixscName = schoolClass.getIxscName();
				String ixsgId = schoolClass.getIxsgId();
				hashMap.put("lineKey", "ixsgId");
				hashMap.put("lineValue", ixsgId);
				SchoolGrade schoolGrade = ixuestarCloudELMapper.getSchoolGrades(hashMap).get(0);
				if (schoolGrade!=null) {
					String ixsgName = schoolGrade.getIxsgName();
					JSONObject teaObject = new JSONObject();
					teaObject.put("ixscId", ixscId);
					teaObject.put("ixscName", ixscName);
					teaObject.put("ixsgId", ixsgId);
					teaObject.put("ixsgName", ixsgName);
					teacherArray.add(teaObject);
				}
			}
		}
		//返回参数
		teacherObject.put("classList", teacherArray);
		teacherObject.put("classNum", teacherArray.size());
		return teacherObject;
	}
	
	@Override
	public JSONObject bindTeacherInfo(JSONObject jsonObject) {
		// TODO Auto-generated method stub
		int code = 0;
		JSONObject bindTeacherObject = new JSONObject();
		//获取参数
		String ixstId = jsonObject.getString("ixstId");
		//首先判断老师的信息是否被绑定
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ixssId");
		hashMap.put("lineValue", ixstId);
		YxWxuser wxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
		if (wxuser!=null) {
			code = 1;
		}else {
			String ywId = jsonObject.getString("ywId");
			JSONArray ixscIds = jsonObject.getJSONArray("ixscIds");
			//首先绑定老师和微信信息
			hashMap.put("lineKey", "ywId");
			hashMap.put("lineValue", ywId);
			YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
			logger.info("-----bind--"+yxWxuser+"------");
			if (yxWxuser!=null) {
				yxWxuser.setIxssId(ixstId);
				ixuestarCloudELMapper.updateYxWxuser(yxWxuser);
			}
			JSONArray jsonArray = new JSONArray();
			Set<Object> hashSet = new HashSet<>();
			//然后绑定老师所带班级的id
			for (int i = 0; i < ixscIds.size(); i++) {
				String ixscId = ixscIds.getString(i);
				JSONObject teacherObject = new JSONObject();
				//判断是否存在了
				hashMap.put("ixscId", ixscId);
				hashMap.put("ixstId", ixstId);
				YxTeacherClass teacherClasse = ixuestarCloudELMapper.getTeacherClasse(hashMap);
				if (teacherClasse==null) {
					YxTeacherClass yxTeacherClass = new YxTeacherClass();
					String ytcId = "ytc" + new Date().getTime() + (int)(Math.random()*10);
					String ytcCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
					yxTeacherClass.setYtcId(ytcId);
					yxTeacherClass.setIxscId(ixscId);
					yxTeacherClass.setIxstId(ixstId);
					yxTeacherClass.setYtcCreatetime(ytcCreatetime);
					ixuestarCloudELMapper.writeTeacherClass(yxTeacherClass);
//					jsonArray.add(yxTeacherClass);
				}else {
//					jsonArray.add(teacherClasse);
				}
				//获取班级信息
				hashMap.put("lineKey", "ixscId");
				hashMap.put("lineValue", ixscId);
				//班级
				SchoolClass schoolClass = ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0);
				logger.info("-----bind-"+schoolClass+"--------");
				if (schoolClass!=null) {
					String ixscName = schoolClass.getIxscName();
					teacherObject.put("ixscId", ixscId);
					teacherObject.put("ixscName", ixscName);
					
					String ixsgId = schoolClass.getIxsgId();
					hashSet.add(ixsgId);
					//获取年级信息
					hashMap.put("lineKey", "ixsgId");
					hashMap.put("lineValue", ixsgId);
					SchoolGrade schoolGrade = ixuestarCloudELMapper.getSchoolGrades(hashMap).get(0);
					if (schoolGrade!=null) {
						String ixsId = schoolGrade.getIxsId();
						String ixsgName = schoolGrade.getIxsgName();
						//年级
						teacherObject.put("ixsgId", ixsgId);
						teacherObject.put("ixsgName", ixsgName);
						hashMap.put("flag", 1);
						hashMap.put("lineKey", "ixsId");
						hashMap.put("lineValue", ixsId);
						School school = ixuestarCloudELMapper.getSchoolInfo(hashMap).get(0);
						logger.info("-----bind-"+school+"--------");
						if (school!=null) {
							String ixsName = school.getIxsName();
							teacherObject.put("ixsId", ixsId);
							teacherObject.put("ixsName", ixsName);
						}
					}
					jsonArray.add(teacherObject);
				}
			}
			//获取年级班级
			JSONArray gradeArray = new JSONArray();
			Iterator<Object> iterator = hashSet.iterator();
			while (iterator.hasNext()) {
				JSONObject gradeObject = new JSONObject();
				String ixsgId = iterator.next().toString();
				hashMap.put("lineKey", "ixsgId");
				hashMap.put("lineValue", ixsgId);
				String ixsgName = ixuestarCloudELMapper.getSchoolGrades(hashMap).get(0).getIxsgName();
				//获取班级列表
				List<SchoolClass> classList = ixuestarCloudELMapper.getSchoolClasses(hashMap);
				gradeObject.put("ixsgId", ixsgId);
				gradeObject.put("ixsgName", ixsgName);
				gradeObject.put("classList", classList);
				gradeArray.add(gradeObject);
			}
			//获取所教科目
			hashMap.put("lineKey", "ixstId");
			hashMap.put("lineValue", ixstId);
			JSONArray teacherSubjectArray = new JSONArray();
			List<YxTeacherSubject> teacherSubjects = ixuestarCloudELMapper.getTeacherSubjects(hashMap);
			logger.info("-----teacherSubjects-"+teacherSubjects+"--------");
			for (int i = 0; i < teacherSubjects.size(); i++) {
				JSONObject teacherSubjectObject = new JSONObject();
				YxTeacherSubject yxTeacherSubject = teacherSubjects.get(i);
				String ixsId = yxTeacherSubject.getIxsId();
				hashMap.put("lineKey", "ixsId");
				hashMap.put("lineValue", ixsId);
				Subject subjectInfo = ixuestarCloudELMapper.getSubjectInfo(hashMap);
				logger.info("-----subjectInfo-"+subjectInfo+"--------");
				if (subjectInfo!=null) {
					String ixsName = subjectInfo.getIxsName();
					teacherSubjectObject.put("ixsId", ixsId);
					teacherSubjectObject.put("ixsName", ixsName);
					teacherSubjectArray.add(teacherSubjectObject);
				}
			}
			
			//获取班主任的积分
			JSONObject headtPObject = new JSONObject();
			hashMap.put("lineKey", "ixstId");
			hashMap.put("lineValue", ixstId);
			YxHeadTeacher yxHeadTeacherInfo = ixuestarCloudELMapper.getYxHeadTeacherInfo(hashMap);
			if (yxHeadTeacherInfo!=null) {
				String ixscId = yxHeadTeacherInfo.getIxscId();
				YxHeadtPoints headtPoints = ixuestarCloudELMapper.getHeadtPoints(ixstId);
				if (headtPoints!=null) {
					Integer yhtpoints = headtPoints.getYhtpoints();
					headtPObject.put("yhtpoints", yhtpoints);
				}else {
					headtPObject.put("yhtpoints", 0);
				}
				headtPObject.put("ixscId", ixscId);
				headtPObject.put("headTeacher", 1);
			}else {
				headtPObject.put("yhtpoints", 0);
				headtPObject.put("ixscId", null);
				headtPObject.put("headTeacher", 0);
			}
			bindTeacherObject.put("headTeacher", headtPObject);
			
			JSONObject wxuserObject = (JSONObject)JSONObject.toJSON(yxWxuser);
			hashMap.put("lineKey", "ixstId");
			hashMap.put("lineValue", ixstId);
			SchoolTeacher schoolTeacher = ixuestarCloudELMapper.getSchoolTeachers(hashMap).get(0);
			logger.info("-----schoolTeacher-"+schoolTeacher+"--------");
			if (schoolTeacher!=null) {
				String ixstName = schoolTeacher.getIxstName();
				wxuserObject.put("ixstName", ixstName);
			}
			wxuserObject.put("gradeClass", gradeArray);
			wxuserObject.put("teacherClass", jsonArray);
			wxuserObject.put("teacherSubject", teacherSubjectArray);
			bindTeacherObject.putAll(wxuserObject);
		}
		bindTeacherObject.put("code", code);
		return bindTeacherObject;
	}
	
	@Override
	public JSONObject upLoadFile(MultipartFile commonsMultipartFile,String ytfName) {
		// TODO Auto-generated method stub
		int code = 0;
		JSONObject fileObject = new JSONObject();
		//创建存放的文件夹
		String dirPath = "/tmp/tempAppPdfFileDir";
//		String dirPath = "E:\\tmp\\tempAppPdfFileDir";
		File file = new File(dirPath);
		if (!file.exists()) {
			file.mkdirs();
		}
		if (!commonsMultipartFile.isEmpty()) {
			//存放文件
			String originalFilename = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())+"."+ytfName.split("\\.")[1];
			String filePath = dirPath + "/" + originalFilename;
//			String filePath = dirPath + "\\" + originalFilename;
			System.out.println("filePath:"+filePath);
//			File comFile = new File(filePath);
			try {
				commonsMultipartFile.transferTo(new File(filePath));
			} catch (IllegalStateException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			String pdfPath = "";
			int ytfPage = 1;
			//判断文件的类型
			String[] nameHouzui = originalFilename.split("\\.");
			if (nameHouzui.length>1) {
				if (nameHouzui[nameHouzui.length-1].contains("doc")) {
					//定义pdf的文件路径
					originalFilename = originalFilename.replace(".doc", ".pdf").replace(".docx", ".pdf").replace(".DOC", ".pdf").replace(".DOCX", ".pdf");
					pdfPath = dirPath + "/" + originalFilename;
					logger.info("-----doc-"+filePath+"-,pdf-"+pdfPath+"----------");
					//转换成pdf文件
					ConvertToPdf.doc2pdf(filePath, pdfPath);
				}else {
					pdfPath = filePath;
				}
			}
			//字节流
			InputStream fileInputStream = null;
			try {
				fileInputStream = new FileInputStream(new File(pdfPath));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			//文件转换为base64位
			String fileToBase64 = "";
			try {
				fileToBase64 = QiniuUpLoad.fileToBase64(fileInputStream);
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
			//上传文件
//			logger.info("-----fileToBase64-"+fileToBase64+",originalFilename-"+originalFilename+"---------");
			String fileUrl = "";
			try {
				fileUrl = "https://cdn.travbao.com/" + new QiniuUpLoad().fileUpLoadQiniu(fileToBase64, originalFilename);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			String headerField = "";
			try {
				headerField = new URL(fileUrl).openConnection().getHeaderField(0);
			} catch (MalformedURLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			
			if (headerField.contains("200") && headerField.contains("OK")) {
				if (originalFilename.contains(".pdf")) {
					//获取pdf文件的页数
					try {
						InputStream fileStream = new FileInputStream(new File(pdfPath));
						ytfPage = new PdfReader(fileStream).getNumberOfPages();
					} catch (Exception e) {
						// TODO: handle exception
						e.printStackTrace();
					}
				}
				try {
					FileControl.deleteFile(pdfPath);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				//上传文件
				String ytfId = "ytf" + new Date().getTime() + (int)(Math.random()*10);
				String ytfCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
				//获取文件大小
				String fileSize = String.format("%.2f", (new File(filePath).length()/1024.0/1024.0));
				YxFile yxFile = new YxFile();
				yxFile.setYtfId(ytfId);
				yxFile.setYtfUrl(fileUrl);
				yxFile.setYtfName(ytfName);
				yxFile.setYtfSize(Double.parseDouble(fileSize));
				yxFile.setYtfPage(ytfPage);
				yxFile.setYtfCreatetime(ytfCreatetime);
				ixuestarCloudELMapper.writeUploadFileInfo(yxFile);
				fileObject.putAll((JSONObject)JSONObject.toJSON(yxFile));
			}else {
				
			}
		}
		fileObject.put("code", code);
		return fileObject;
	}
	
	@Override
	public JSONObject preFileOrder(String ytoId,int printNum,int printTotal,int orderType,String ywId,String ytoName, Integer ytoDoubleSide) {
		// TODO Auto-generated method stub
		//判断订单类型 如果类型是0说明是班级分发；如果类型是1说明是自行下单
		String isPay = "Y";
		int code = 0;
		JSONObject jsonObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		//首先获取订单的套餐类型及id
		hashMap.put("lineKey", "yopType");
		hashMap.put("lineValue", orderType);
		YxOrderPackage yxOrderPackage = ixuestarCloudELMapper.getYxOrderPackage(hashMap);
		if (yxOrderPackage!=null) {
			double yopPrice = yxOrderPackage.getYopPrice();
			double yopDiscount = yxOrderPackage.getYopDiscount();
			double yopReduction = yxOrderPackage.getYopReduction();
			//计算总页数
			int total = printNum * printTotal;
			//计算总额
			double totalAmount = total * yopPrice * yopDiscount + yopReduction;
			double discountAmount = totalAmount * yopPrice * (1-yopDiscount) - yopReduction;
			//创建订单
			Yxtorder yxtorder = new Yxtorder();

			String ytoCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			//生成打印码
			String ytoPrintCode = "";
			boolean istrue = true;
			while (istrue) {
				String valueOf = String.valueOf((int)((Math.random()*9+1)*1000));
				hashMap.put("lineKey", "ytoPrintCode");
				hashMap.put("lineValue", valueOf);
				Yxtorder yxtorderInfo = ixuestarCloudELMapper.getYxtorderInfo(hashMap);
				if (yxtorderInfo==null) istrue = false;ytoPrintCode=valueOf;
			}
			yxtorder.setYtoId(ytoId);
			yxtorder.setYtoName(ytoName);
			yxtorder.setYtoType(orderType);
			yxtorder.setYtoAmount(totalAmount);
			yxtorder.setYtoDiscount(discountAmount);
			yxtorder.setYtoDoubleSide(ytoDoubleSide);
			yxtorder.setYtoPrintNum(printNum);
			yxtorder.setYtoPrintCode(ytoPrintCode);
			yxtorder.setYtoCreatetime(ytoCreatetime);
			ixuestarCloudELMapper.writeFileOrder(yxtorder);
//			jsonObject.putAll((JSONObject)(JSONObject.toJSON(yxtorder)));
			if (orderType==0 || (int)totalAmount==0) {
            	//修改订单的状态
            	hashMap.put("lineKey", "ptoPayStatus");
            	hashMap.put("lineValue", "1");
            	hashMap.put("ytoId", ytoId);
            	ixuestarCloudELMapper.updateOrderStatus(hashMap);
            	isPay = "N";
			}
		}else {
			code = 1;
		}
		jsonObject.put("code", code);
		jsonObject.put("isPay", isPay);
		return jsonObject;
	}
	
	@Override
	public String writeOrderFile(JSONArray jsonArray, String ytoId) {
		// TODO Auto-generated method stub
		String ytfNames = "";
		//写入文件关联
		for (int i = 0; i < jsonArray.size(); i++) {
			//获取文件的单个对象
			JSONObject jsonObject = jsonArray.getJSONObject(i);
			String ytfId = "",ytfName = "";
			if (jsonObject.containsKey("ytfId")) {
				ytfId = jsonObject.getString("ytfId");
				ytfName = jsonObject.getString("ytfName");
			}else {
				ytfName = jsonObject.getString("ytfName");
				String ytfUrl = jsonObject.getString("ytfUrl");
				int ytfPage = jsonObject.getInteger("ytfPage");
				//获取需要的张数
				int ytfNum = ytfPage / 2;
				int ytfSheet = ytfPage%2==0?ytfNum:ytfNum+1;
				double ytfSize = jsonObject.getDouble("ytfSize");
				//写入文件信息
				//上传文件
				ytfId = "ytf" + new Date().getTime() + (int)(Math.random()*10);
				String ytfCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
				YxFile yxFile = new YxFile();
				yxFile.setYtfId(ytfId);
				yxFile.setYtfUrl(ytfUrl);
				yxFile.setYtfName(ytfName);
				yxFile.setYtfSize(ytfSize);
				yxFile.setYtfPage(ytfPage);
				yxFile.setYtfSheet(ytfSheet);
				yxFile.setYtfCreatetime(ytfCreatetime);
				ixuestarCloudELMapper.writeUploadFileInfo(yxFile);
			}
			//写入数据
			YxOrderFile yxOrderFile = new YxOrderFile();
			String ytofId = "ytof" + new Date().getTime() + (int)(Math.random()*10);
			yxOrderFile.setYtofId(ytofId);
			yxOrderFile.setYtoId(ytoId);
			yxOrderFile.setYtfId(ytfId);
			ixuestarCloudELMapper.writeOrderFile(yxOrderFile);
			if (ytfNames.equals("")) {
				ytfNames = ytfName;
			}else {
				ytfNames = ytfNames + "_" + ytfName;
			}
		}
		return ytfNames;
	}
	
	@Override
	public JSONArray writeOrderClass(JSONArray jsonArray, String ytoId, String ixsId) {
		// TODO Auto-generated method stub
		//写入班级关联
		JSONArray jsonArray2 = new JSONArray();
		Map<String, Object> hashMap = new HashMap<>();
		for (int i = 0; i < jsonArray.size(); i++) {
			String ixscId = jsonArray.getString(i);
			JSONObject jsonObject = new JSONObject();
			//获取班级信息
			hashMap.put("lineKey", "ixscId");
			hashMap.put("lineValue", ixscId);
			SchoolClass schoolClass = ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0);
			String ixsgId = schoolClass.getIxsgId();
			jsonObject.put("ixscName", schoolClass.getIxscName());
			hashMap.put("lineKey", "ixsgId");
			hashMap.put("lineValue", ixsgId);
			SchoolGrade schoolGrade = ixuestarCloudELMapper.getSchoolGrades(hashMap).get(0);
			jsonObject.put("ixsgName", schoolGrade.getIxsgName());
			hashMap.put("lineKey", "ixsId");
			hashMap.put("lineValue", ixsId);
			String ixsName = ixuestarCloudELMapper.getSubjectInfo(hashMap).getIxsName();
			jsonObject.put("ixsName", ixsName);
			jsonArray2.add(jsonObject);
			//写入数据
			YxOrderClass yxOrderClass = new YxOrderClass();
			String ytocId = "ytoc" + new Date().getTime() + (int)(Math.random()*10);
			yxOrderClass.setYtocId(ytocId);
			yxOrderClass.setYtoId(ytoId);
			yxOrderClass.setIxscId(ixscId);
			yxOrderClass.setIxsId(ixsId);
			ixuestarCloudELMapper.writeOrderClass(yxOrderClass);
		}
		return jsonArray2;
	}
	
	@Override
	public JSONObject writeOrderUser(String ytoId, String ywId) {
		// TODO Auto-generated method stub
		//创建关系id
		String ywoId = "ywo" + new Date().getTime()+(int)(Math.random()*10);
		YxWxuserOrder yxWxuserOrder = new YxWxuserOrder();
		yxWxuserOrder.setYwoId(ywoId);
		yxWxuserOrder.setYtoId(ytoId);
		yxWxuserOrder.setYwId(ywId);
		ixuestarCloudELMapper.writeOrderUser(yxWxuserOrder);
		return (JSONObject)(JSONObject.toJSON(yxWxuserOrder));
	}
	
	@Override
	public JSONObject getFileOrderInfo(String ytoId) {
		// TODO Auto-generated method stub
		JSONObject jsonObject = new JSONObject();
		int code = 0;
		//首先获取订单详情
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ytoId");
		hashMap.put("lineValue", ytoId);
		Yxtorder yxtorderInfo = ixuestarCloudELMapper.getYxtorderInfo(hashMap);
		if (yxtorderInfo!=null) {
			//然后判断订单类型
			Integer ytoType = yxtorderInfo.getYtoType();
			if (ytoType==0) {
				//1、获取班级和科目
				String ixsName = "";
				JSONArray jsonArray = new JSONArray();
				List<YxOrderClass> orderClass = ixuestarCloudELMapper.getOrderClass(hashMap);
				for (int i = 0; i < orderClass.size(); i++) {
					JSONObject jsonObject2 = new JSONObject();
					YxOrderClass yxOrderClass = orderClass.get(i);
					String ixscId = yxOrderClass.getIxscId();
					hashMap.put("lineKey", "ixscId");
					hashMap.put("lineValue", ixscId);
					SchoolClass schoolClass = ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0);
					String ixscName = schoolClass.getIxscName();
					jsonObject2.put("ixscName", ixscName);
					String ixsgId = schoolClass.getIxsgId();
					hashMap.put("lineKey", "ixsgId");
					hashMap.put("lineValue", ixsgId);
					SchoolGrade schoolGrade = ixuestarCloudELMapper.getSchoolGrades(hashMap).get(0);
					String ixsgName = schoolGrade.getIxsgName();
					jsonObject2.put("ixsgName", ixsgName);
					String ixsId = yxOrderClass.getIxsId();
					hashMap.put("lineKey", "ixsId");
					hashMap.put("lineValue", ixsId);
					Subject subjectInfo = ixuestarCloudELMapper.getSubjectInfo(hashMap);
					ixsName = subjectInfo.getIxsName();
					jsonArray.add(jsonObject2);
				}
				jsonObject.put("orderClass", jsonArray);
				jsonObject.put("orderSubject", ixsName);
				jsonObject.put("orderInfo", yxtorderInfo);
			}else if (ytoType==1) {
				jsonObject.put("orderInfo", yxtorderInfo);
			}
		}else {
			code = 1;
		}
		jsonObject.put("code", code);
		return jsonObject;
	}
	
	@Override
	public JSONObject getFileOrderList(String ywId, Integer pageIndex, Integer pageLimit,int orderStatus) {
		// TODO Auto-generated method stub
		JSONObject orderObject = new JSONObject();
		//首先定义查询的起始数
		int pageFirstResult = (pageIndex - 1) * pageLimit;
		int pageLimitResult = pageLimit;
		//首先获取订单的总数
		JSONArray orderArray = new JSONArray();
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("flag", 0);
		hashMap.put("flag0", 0);
		hashMap.put("lineKey", "ywId");
		hashMap.put("lineValue", ywId);
		logger.info("----hashMap-"+hashMap+"------");
		int resultTotal = ixuestarCloudELMapper.getOrderUser(hashMap).size();
		logger.info("----resultTotal-"+resultTotal+"------");
		//获取订单列表
		hashMap.put("flag", 1);
		if (orderStatus==0) {
			hashMap.put("flag0", 0);
		}else if (orderStatus==1) {
			hashMap.put("flag0", 1);
			hashMap.put("ytoPrintStatus", 0);
		}else if (orderStatus==2) {
			hashMap.put("flag0", 1);
			hashMap.put("ytoPrintStatus", 1);
		}
		hashMap.put("firstResult", pageFirstResult);
		hashMap.put("limitResult", pageLimitResult);
		List<YxWxuserOrder> orderUser = ixuestarCloudELMapper.getOrderUser(hashMap);
		for (int i = 0; i < orderUser.size(); i++) {
			JSONObject jsonObject = new JSONObject();
			//获取单个订单和微信关联对象
			YxWxuserOrder yxWxuserOrder = orderUser.get(i);
			//获取订单信息id
			String ytoId = yxWxuserOrder.getYtoId();
			hashMap.put("lineKey", "ytoId");
			hashMap.put("lineValue", ytoId);
			Yxtorder yxtorderInfo = ixuestarCloudELMapper.getYxtorderInfo(hashMap);
			if (yxtorderInfo!=null) {
				//然后判断订单类型
				Integer ytoType = yxtorderInfo.getYtoType();
				int ytoPrintStatus = yxtorderInfo.getYtoPrintStatus();
				JSONObject orderInfoObject = (JSONObject)JSONObject.toJSON(yxtorderInfo);
				if (ytoPrintStatus==0) {
					orderInfoObject.put("orderStatus", "未完成");
				}else {
					orderInfoObject.put("orderStatus", "已完成");
				}
				if (ytoType==0) {
					//1、获取班级和科目
					String ixsName = "";
					JSONArray jsonArray = new JSONArray();
					List<YxOrderClass> orderClass = ixuestarCloudELMapper.getOrderClass(hashMap);
					for (int j = 0; j < orderClass.size(); j++) {
						JSONObject jsonObject2 = new JSONObject();
						YxOrderClass yxOrderClass = orderClass.get(j);
						String ixscId = yxOrderClass.getIxscId();
						hashMap.put("lineKey", "ixscId");
						hashMap.put("lineValue", ixscId);
						SchoolClass schoolClass = ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0);
						String ixscName = schoolClass.getIxscName();
						jsonObject2.put("ixscName", ixscName);
						String ixsgId = schoolClass.getIxsgId();
						hashMap.put("lineKey", "ixsgId");
						hashMap.put("lineValue", ixsgId);
						SchoolGrade schoolGrade = ixuestarCloudELMapper.getSchoolGrades(hashMap).get(0);
						String ixsgName = schoolGrade.getIxsgName();
						jsonObject2.put("ixsgName", ixsgName);
						String ixsId = yxOrderClass.getIxsId();
						hashMap.put("lineKey", "ixsId");
						hashMap.put("lineValue", ixsId);
						Subject subjectInfo = ixuestarCloudELMapper.getSubjectInfo(hashMap);
						ixsName = subjectInfo.getIxsName();
						jsonArray.add(jsonObject2);
					}
					jsonObject.put("orderClass", jsonArray);
					jsonObject.put("orderSubject", ixsName);
					jsonObject.put("orderInfo", orderInfoObject);
				}else if (ytoType==1) {
					jsonObject.put("orderInfo", orderInfoObject);
				}
				orderArray.add(jsonObject);
			}
		}
		//获取总的页数
		int pageWhole = resultTotal/pageLimit;
		int pageRemain = resultTotal%pageLimit;
		int pageTotal = (pageRemain==0?pageWhole:pageWhole+1);
		//获取返回对象
		orderObject.put("TotalPage", pageTotal);
		orderObject.put("orderList", orderArray);
		orderObject.put("currentPage", pageIndex);
		orderObject.put("resultTotal", resultTotal);
		return orderObject;
	}
	
	@Override
	public JSONObject getClockInClass(String ixscId, Integer pageIndex, Integer pageLimit) {
		// TODO Auto-generated method stub
		//获取班级签到对象
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("ixscId", ixscId);
		JSONArray jsonArray = new JSONArray();
		//获取班级人数
		hashMap.put("lineKey", "ixscId");
		hashMap.put("lineValue", ixscId);
		int totalStudent = ixuestarCloudELMapper.getSchoolStudents(hashMap).size();
		//计算开始日期条数
		Integer pageEnd = pageIndex * pageLimit;
		Integer pageFirst = (pageIndex-1) * pageLimit + 1;
		for (int i = pageFirst; i <= pageEnd; i++) {
			//获取日期
			Calendar instance = Calendar.getInstance();
			instance.add(Calendar.DATE, -i);
			String format = new SimpleDateFormat("yyyy-MM-dd").format(instance.getTime());
			hashMap.put("ycDate", format);
			YxClassClockin yxClassClockin = ixuestarCloudELMapper.getYxClassClockin(hashMap);
			if(yxClassClockin!=null) {
				yxClassClockin.setYcBinNum(totalStudent);
				jsonArray.add(yxClassClockin);				
			}else {
				YxClassClockin yxClassClockin2 = new YxClassClockin();
				yxClassClockin2.setYcDate(format);
				yxClassClockin2.setYcBinNum(totalStudent);
				jsonArray.add(yxClassClockin2);
			}
		}
		//返回对象
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("currentPage", pageIndex);
		jsonObject.put("numberPage", pageLimit);
		jsonObject.put("classClockin", jsonArray);
		return jsonObject;
	}

	@Override
	public JSONObject getSigninListudents(String ixscId, String ycDate) {
		// TODO Auto-generated method stub
		//首先获取班级人数总列表
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ixscId");
		hashMap.put("lineValue", ixscId);
		List<SchoolStudent> schoolStudents = ixuestarCloudELMapper.getSchoolStudents(hashMap);
		//获取签到列表
		hashMap.put("ycDate", ycDate);
		hashMap.put("ixscId", ixscId);
		List<SchoolStudent> signinListudents = ixuestarCloudELMapper.getSigninListudents(hashMap);
		Set<String> hashSet = new HashSet<>();
		schoolStudents.stream().forEach(ss -> {
			if (!signinListudents.contains(ss)) {
				hashSet.add(ss.getIxssName());
			}
		});
		//定义状态码
		int code = 0;
		if (hashSet.isEmpty()) code = 1;
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("code", code);
		jsonObject.put("noSigninStudent", hashSet);
		jsonObject.put("noSigninStudentNum", hashSet.size());
		return jsonObject;
	}
	
	@Override
	public JSONObject getDateClockInClass(String ixscId, String startDate, String stopDate) {
		// TODO Auto-generated method stub
		//获取签到列表
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("ixscId", ixscId);
		hashMap.put("ycStopDate", stopDate);
		hashMap.put("ycStartDate", startDate);
		List<YxClassClockin> yxClassClockinsDate = ixuestarCloudELMapper.getYxClassClockinsDate(hashMap);
		//签到列表
		int code = 0;
		if (yxClassClockinsDate.size()==0) code = 1;
		//添加json
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("code", code);
		jsonObject.put("classClockin", yxClassClockinsDate);
		jsonObject.put("classClockinNum", yxClassClockinsDate.size());
		//返回
		return jsonObject;
	}
	
	@Override
	public JSONObject getHeadTeacherPoints(String ixstId) {
		// TODO Auto-generated method stub
		//获取班主任获取对象
		YxHeadtPoints headtPoints = ixuestarCloudELMapper.getHeadtPoints(ixstId);
		//转换
		JSONObject jsonObject = (JSONObject)JSON.toJSON(headtPoints);
		return jsonObject;
	}
	
	@Override
	public JSONObject getApplicationForWithdrawal(String ybcName, String ybcIdCard, String ybcCreditcard,
			String ybcBankName, String ywId, double ywoAmount) {
		// TODO Auto-generated method stub
		int code = 0;
		JSONObject jsonObject = new JSONObject();
		//首先查询是否存在此用户
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ywId");
		hashMap.put("lineValue", ywId);
		YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
		if (yxWxuser!=null) {
			//判断是否达到提现标准
			if (ywoAmount>=50) {
				//判断本月是否提现过
				String ywDate = new SimpleDateFormat("yyyy-MM").format(new Date());
				hashMap.put("flag", 1);
				hashMap.put("ywDate", ywDate);
				List<WithdrawalOrder> withdrawalOrdersList = ixuestarCloudELMapper.getWithdrawalOrdersList(hashMap);
				if (withdrawalOrdersList.size()==0) {
					//判断是否存在银行卡信息
					BankcardInfo bankcardInfo = ixuestarCloudELMapper.getBankcardInfo(hashMap);
					if (bankcardInfo==null) {
						//首先写入银行卡信息
						BankcardInfo bankcardInfo1 = new BankcardInfo();
						//创建主键信息和时间
						String ybcId = "ybc" + new Date().getTime() + (int)(Math.random()*10);
						String ybcCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
						bankcardInfo1.setYbcId(ybcId);
						bankcardInfo1.setYbcName(ybcName);
						bankcardInfo1.setYbcIdCard(ybcIdCard);
						bankcardInfo1.setYbcCreditcard(ybcCreditcard);
						bankcardInfo1.setYbcBankName(ybcBankName);
						bankcardInfo1.setYwId(ywId);
						bankcardInfo1.setYbcCreatetime(ybcCreatetime);
						ixuestarCloudELMapper.writeBankcardInfo(bankcardInfo1);
						jsonObject.put("bankcardInfo", bankcardInfo1);
						
						bankcardInfo = bankcardInfo1;
					}else {
						bankcardInfo.setYbcName(ybcName);
						bankcardInfo.setYbcIdCard(ybcIdCard);
						bankcardInfo.setYbcCreditcard(ybcCreditcard);
						bankcardInfo.setYbcBankName(ybcBankName);
						ixuestarCloudELMapper.updateBankcardInfo(bankcardInfo);
						jsonObject.put("bankcardInfo", bankcardInfo);
					}
					//创建订单信息
					WithdrawalOrder withdrawalOrder = new WithdrawalOrder();
					//定义提现信息主键和创建时间
					String ywoId = "ywo" + new Date().getTime() + (int)(Math.random()*10);
					String ywoCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
					withdrawalOrder.setYwoId(ywoId);
					withdrawalOrder.setYwoAmout(ywoAmount);
					withdrawalOrder.setYwoCreditcard(ybcCreditcard);
					withdrawalOrder.setYwId(ywId);
					withdrawalOrder.setYwoCreatetime(ywoCreatetime);
					ixuestarCloudELMapper.writeWithdrawalOrder(withdrawalOrder);
					//修改教师积分
					YxHeadtPoints yxHeadtPoints = new YxHeadtPoints();
					String ixssId = yxWxuser.getIxssId();
					yxHeadtPoints.setYhtpoints(0);
					yxHeadtPoints.setIxstId(ixssId);
					ixuestarCloudELMapper.updateYxHeadtPoints(yxHeadtPoints);
					//发送邮件
					List<Temp> yxEmailInfo = ixuestarCloudELMapper.getYxEmailInfo("1");
					for (int i = 0; i < yxEmailInfo.size(); i++) {
						Temp temp = yxEmailInfo.get(i);
						//获取
						String b = temp.getB();
						MailUtil.sendCommonMail1(b, b, bankcardInfo, withdrawalOrder, yxWxuser);
					}
					jsonObject.put("withdrawalOrder", withdrawalOrder);
					jsonObject.put("withdrawalOrder", withdrawalOrder);
				}else {
					code = 1;
				}
			}else {
				code = 2;
			}
		}
		jsonObject.put("code", code);
		return jsonObject;
	}
	
	@Override
	public JSONObject getBankcardInfo(String ywId) {
		// TODO Auto-generated method stub
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ywId");
		hashMap.put("lineValue", ywId);
		BankcardInfo bankcardInfo = ixuestarCloudELMapper.getBankcardInfo(hashMap);
		//转换
		JSONObject jsonObject = (JSONObject)JSON.toJSON(bankcardInfo);
		return jsonObject;
	}
	
	@Override
	public JSONObject updateBankcardInfo(JSONObject jsonObject) {
		// TODO Auto-generated method stub
		//首先json转换对象
		BankcardInfo parseObject = JSON.parseObject(jsonObject.toJSONString(), BankcardInfo.class);
		//执行
		ixuestarCloudELMapper.updateBankcardInfo(parseObject);
		return jsonObject;
	}
	
	@Override
	public JSONObject getWithdrawalList(String ywId, Integer pageIndex, Integer pageSize) {
		// TODO Auto-generated method stub
		//定义页码索引
		Integer firstResult = (pageIndex - 1) * pageSize;
		Integer limitResult = pageSize;
		//创建容易
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("flag", 0);
		hashMap.put("lineKey", "ywId");
		hashMap.put("lineValue", ywId);
		int total = ixuestarCloudELMapper.getWithdrawalOrdersList(hashMap).size();
		//计算总页数
		int remainPage = total / pageSize;
		int totalPage = total % pageSize == 0 ? remainPage : remainPage+1;
		//展示
		hashMap.put("flag", 2);
		hashMap.put("firstResult", firstResult);
		hashMap.put("limitResult", limitResult);
		List<WithdrawalOrder> withdrawalOrdersList = ixuestarCloudELMapper.getWithdrawalOrdersList(hashMap);
		JSONObject jsonObject = new JSONObject();	
		jsonObject.put("totalResult", total);
		jsonObject.put("totalPage", totalPage);
		jsonObject.put("currentPage", pageIndex);
		jsonObject.put("dataCurrentPage", withdrawalOrdersList);
		//返回
		return jsonObject;
	}
	
	@Override
	public JSONObject getClassAddressBook(String ixstId, String ixscId) {
		// TODO Auto-generated method stub
		int code = 0;
		JSONObject jsonObject = new JSONObject();
		//判断获取的班级是否是所教的班级
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("ixstId", ixstId);
		hashMap.put("ixscId", ixscId);
		YxTeacherClass teacherClasse = ixuestarCloudELMapper.getTeacherClasse(hashMap);
		if (teacherClasse!=null) {
			Temp classBindin = ixuestarCloudELMapper.getClassBindingNum(ixscId);
			//首先获取绑定的人数
			String classBindingNum = classBindin==null?"0":classBindin.getA();
			//获取绑定信息		
			List<Temp> classBindingStuInfo = ixuestarCloudELMapper.getClassBindingStuInfo(ixscId);
			//加入信息
			if (Integer.parseInt(classBindingNum)==0) {
				code = 2;
			}else {
				jsonObject.put("classBindingNum", classBindingNum);
				jsonObject.put("classBindingStuInfo", classBindingStuInfo);
			}
		}else {
			code = 1;
		}
		jsonObject.put("code", code);
		return jsonObject;
	}
	
	@Override
	public JSONObject writeClassSchedule(List<YxClassschedule> list, Integer issueCode) {
		// TODO Auto-generated method stub
		JSONObject jsonObject = new JSONObject();
		//修改课程表
		for (int i = 0; i < list.size(); i++) {
			YxClassschedule yxClassschedule = list.get(i);
			yxClassschedule.setYcsStatus(issueCode);
			//修改课程表
			ixuestarCloudELMapper.updateClasschedules(yxClassschedule);
		}
		return jsonObject;
	}
	
	@Override
	public JSONObject getClassSubjectInfo(Integer ysPhases, Integer ysStatus) {
		// TODO Auto-generated method stub
		int code = 0;
		JSONObject jsonObject = new JSONObject();
		//获取列表
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("ysPhases", ysPhases);
		hashMap.put("ysStatus", ysStatus);
		List<YxSubject> yxSubjectsInfo = ixuestarCloudELMapper.getYxSubjectsInfo(hashMap);
		//返回结果
		if (yxSubjectsInfo.size()==0) {
			code = 1;
		}else {
			jsonObject.put("subjectList", yxSubjectsInfo);
			jsonObject.put("subjectListSize", yxSubjectsInfo.size());			
		}
		jsonObject.put("code", code);
		return jsonObject;
	}
	
	@Override
	public JSONObject getClassSchedule(String ixscId) {
		// TODO Auto-generated method stub
		JSONObject resultObject = new JSONObject();
		int code = 0;
		Integer ywcWeek = 0;
		Integer ywcClass = 0;
		//首先获取是否存在课程表
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("flag", 0);
		hashMap.put("fllag", 0);
		hashMap.put("ixscId", ixscId);
		List<YxClassschedule> classschedules = ixuestarCloudELMapper.getClassschedules(hashMap);
		//如果不存在 则首先创建 创建完在进行查询
		if (classschedules.isEmpty()) {
			//首先查询该班级的框架
			hashMap.put("lineKey", "ixscId");
			hashMap.put("lineValue", ixscId);
			SchoolClass schoolClass = ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0);
			if (schoolClass!=null) {
				String ixsgId = schoolClass.getIxsgId();
				
				YxWeeksClass yxWeeksClassInfo = ixuestarCloudELMapper.getYxWeeksClassInfo(ixsgId);
				if (yxWeeksClassInfo!=null) {
					ywcWeek = yxWeeksClassInfo.getYwcWeek();
					ywcClass = yxWeeksClassInfo.getYwcClass();
					//写入课程表
					for (int i = 1; i <= ywcWeek; i++) {
						for (int j = 1; j <= ywcClass; j++) {
							String ycsId = "ycs" + new Date().getTime()+(int)(Math.random()*10)+(int)(Math.random()*10)+(int)(Math.random()*10)+(int)(Math.random()*10);
							String ycsCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
							//写入
							YxClassschedule yxClassschedule = new YxClassschedule();
							yxClassschedule.setYcsId(ycsId);
							yxClassschedule.setYcsNo(j);
							yxClassschedule.setYcsWeeks(i);
							yxClassschedule.setIxsName("");
							yxClassschedule.setIxscId(ixscId);
							yxClassschedule.setYcsStatus(0);
							yxClassschedule.setYcsCreatetime(ycsCreatetime);
							ixuestarCloudELMapper.writeClassschedules(yxClassschedule);
						}
					}
					resultObject.put("ywcWeek", ywcWeek);
					resultObject.put("ywcClass", ywcClass);
					resultObject.put("classscheduleNum", ywcClass*ywcWeek);
				}else {
					code = 2;
				}
			}else {
				code = 1;
			}
		}else {
			//首先查询该班级的框架
			hashMap.put("lineKey", "ixscId");
			hashMap.put("lineValue", ixscId);
			SchoolClass schoolClass = ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0);
			if (schoolClass!=null) {
				String ixsgId = schoolClass.getIxsgId();
				
				YxWeeksClass yxWeeksClassInfo = ixuestarCloudELMapper.getYxWeeksClassInfo(ixsgId);
				if (yxWeeksClassInfo!=null) {
					ywcWeek = yxWeeksClassInfo.getYwcWeek();
					ywcClass = yxWeeksClassInfo.getYwcClass();

					resultObject.put("ywcWeek", ywcWeek);
					resultObject.put("ywcClass", ywcClass);
					resultObject.put("classscheduleNum", ywcClass*ywcWeek);
				}else {
					code = 2;
				}
			}else {
				code = 1;
			}
		}
		//然后查询出并反馈给前端
		List<YxClassschedule> classscheduless = ixuestarCloudELMapper.getClassschedules(hashMap);
		resultObject.put("code", code);
		resultObject.put("classscheduless", classscheduless);
		return resultObject;
	}
	
	@Override
	public JSONObject writeIssueClassNoticeInfo(Integer ycnFlag, Integer ycnType, String ycnContent, Integer ycnAnwType, String ixstId, JSONArray list, JSONArray fileList) {
		// TODO Auto-generated method stub
		int code = 0;
		String ixsccId = "";
		JSONObject resultObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		//查询库中的通知信息
		String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		hashMap.put("date", date);
		hashMap.put("ixstId", ixstId);
		hashMap.put("ycnFlag", ycnFlag);
		List<Issueclassnotice> issueclassnotices = ixuestarCloudELMapper.getIssueclassnotices(hashMap);
		if (issueclassnotices.size()<5) {
			//首先将老师发布的信息存入数据库
			String ycnId = "ycn" + new Date().getTime() + (int)(Math.random()*10);
			String ycnCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			//写入
			Issueclassnotice issueclassnotice = new Issueclassnotice();
			issueclassnotice.setYcnId(ycnId);
			issueclassnotice.setYcnFlag(ycnFlag);
			issueclassnotice.setYcnType(ycnType);
			issueclassnotice.setYcnContent(ycnContent);
			issueclassnotice.setYcnAnwType(ycnAnwType);
			issueclassnotice.setYcnStatus(1);
			issueclassnotice.setYcnCreatetime(ycnCreatetime);
			issueclassnotice.setIxstId(ixstId);
			ixuestarCloudELMapper.writeIssueclassnotice(issueclassnotice);
			//写入关联的班级
			for (int i = 0; i < list.size(); i++) {
				String ixscId = list.getString(i);
				//创建
				String yicId = "yic" + (new Date().getTime()+i+(int)(Math.random()*100)) + (int)(Math.random()*10);
				YxIcnClass yxIcnClass = new YxIcnClass();
				yxIcnClass.setYicId(yicId);
				yxIcnClass.setYcnId(ycnId);
				yxIcnClass.setIxscId(ixscId);
				yxIcnClass.setYicCreatetime(ycnCreatetime);
				ixuestarCloudELMapper.writeYxIcnClassesInfo(yxIcnClass);
				//赋值全局变量
				ixsccId = ixscId;
			}
			//写入关联的文件
			hashMap.put("ycnId",ycnId);
			for (int i = 0; i < fileList.size(); i++) {
				//获取对象
				String ycfId = fileList.getString(i);
				hashMap.put("ycfId",ycfId);
				//写入信息
				ixuestarCloudELMapper.updateIssueclassFiles(hashMap);
			}
			//判断老师要发布的年级学生家长绑定信息
			//创建发送给各家长的信息
			hashMap.put("lineKey", "ycnId");
			hashMap.put("lineValue", ycnId);
			List<IssueclassFile> issueclassFilesList = ixuestarCloudELMapper.getIssueclassFilesList(hashMap);
			//转换信息对象
			JSONObject jsonObject = (JSONObject)JSONObject.toJSON(issueclassnotice);
			jsonObject.put("ycnFileList", issueclassFilesList);
			//消息发送给各个用户
			for (int i = 0; i < list.size(); i++) {
				String ixscId = list.getString(i);
				//获取班级学生
				hashMap.put("lineKey", "ixscId");
				hashMap.put("lineValue", ixscId);
				List<SchoolStudent> schoolStudents = ixuestarCloudELMapper.getSchoolStudents(hashMap);
				for (int j = 0; j < schoolStudents.size(); j++) {
					String ixssId = schoolStudents.get(j).getIxssId();
					//获取微信绑定信息
					hashMap.put("lineKey", "ixssId");
					hashMap.put("lineValue", ixssId);
					YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
					if (yxWxuser!=null) {
						String ywId = yxWxuser.getYwId();
						try {
							WebSocketController.sendInfo(jsonObject.toJSONString(), ywId);
						} catch (IOException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}
				}
			}
			if (ycnFlag==0) {
				//给老师记录积分
				updateTeacherPoints(ycnId, ixsccId, ixstId, "", 2);			
			}else if (ycnFlag==1) {
				//给老师记录积分
				updateTeacherPoints(ycnId, ixsccId, ixstId, "", 3);
			}
			resultObject.putAll(jsonObject);
		}else {
			code = 1;
		}
		resultObject.put("code", code);
		//返回
		return resultObject;
	}
	
	@Override
	public JSONObject getIssueclassnoticeList(Integer ycnFlag,Integer requestType, String ixscId, String ixstId, Integer pageIndex, Integer pageLimit) {
		// TODO Auto-generated method stub
		JSONObject jsonObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		if (requestType==0) {
			//获取通知列表
			hashMap.put("ycnFlag", ycnFlag);
			hashMap.put("lineKey", "ixscId");
			hashMap.put("lineValue", ixscId);
			int total = ixuestarCloudELMapper.getYxIcnClassesList(hashMap).size();
			//定义页码
			Integer limitResult = pageLimit;
			Integer firstResult = (pageIndex - 1) * pageLimit;
			hashMap.put("flag", 1);
			hashMap.put("limitResult", limitResult);
			hashMap.put("firstResult", firstResult);
			//获取
			JSONArray jsonArray = new JSONArray();
			List<YxIcnClass> icnClasses = ixuestarCloudELMapper.getYxIcnClassesList(hashMap);
			for (int i = 0; i < icnClasses.size(); i++) {
				YxIcnClass yxIcnClass = icnClasses.get(i);
				//获取通知id
				String ycnId = yxIcnClass.getYcnId();
				hashMap.put("flag", 0);
				hashMap.put("fllag", 0);
				hashMap.put("flllag", 0);
				hashMap.put("lineKey", "ycnId");
				hashMap.put("lineValue", ycnId);
				Issueclassnotice issueclassnotice = ixuestarCloudELMapper.getYxIssueclassnotices(hashMap).get(0);
				if (issueclassnotice!=null) {
					String ixstId0 = issueclassnotice.getIxstId();
					hashMap.put("lineKey", "ixstId");
					hashMap.put("lineValue", ixstId0);
					List<SchoolTeacher> schoolTeachers = ixuestarCloudELMapper.getSchoolTeachers(hashMap);
					if (schoolTeachers.size()!=0) {
						String ixstName = schoolTeachers.get(0).getIxstName();
						Integer ycnAnwType = issueclassnotice.getYcnAnwType();
						JSONObject issuenoticeObject = (JSONObject)JSON.toJSON(issueclassnotice);
						issuenoticeObject.put("ixstName", ixstName);
						//获取通知的文件信息
						hashMap.put("flag", 0);
						hashMap.put("fllag", 0);
						hashMap.put("flllag", 0);
						hashMap.put("lineKey", "ycnId");
						hashMap.put("lineValue", ycnId);
						List<IssueclassFile> issueclassFilesList = ixuestarCloudELMapper.getIssueclassFilesList(hashMap);
						issuenoticeObject.put("ycnFileList", issueclassFilesList);
						//获取查看的人数和未查看的人数
						hashMap.put("flag", 1);
						hashMap.put("fllag", 0);
						hashMap.put("flllag", 0);
						hashMap.put("ycnId", ycnId);
						hashMap.put("ixscId", ixscId);
						Integer checkNoticeNum = ixuestarCloudELMapper.getYxChecknoticesInfo(hashMap).size();
						hashMap.put("lineKey", "ixscId");
						hashMap.put("lineValue", ixscId);
						int totalNoticeNum = ixuestarCloudELMapper.getSchoolStudents(hashMap).size();
						issuenoticeObject.put("checkNoticeNum", checkNoticeNum);
						issuenoticeObject.put("totalNoticeNum", totalNoticeNum);
						//获取是否查看
						JSONObject replyObject = new JSONObject();
						if (ycnAnwType==0) {
							hashMap.put("flag", 0);
							hashMap.put("fllag", 0);
							hashMap.put("flllag", 1);
							hashMap.put("ycnId", ycnId);
							hashMap.put("ixssId", ixstId);
							List<YxChecknotice> yxChecknoticesInfo = ixuestarCloudELMapper.getYxChecknoticesInfo(hashMap);
							if (yxChecknoticesInfo.size()==0) {
								issuenoticeObject.put("icheck", 0);
							}else {
								issuenoticeObject.put("icheck", 1);
							}
						}else {
							hashMap.put("flag", 0);
							hashMap.put("fllag", 0);
							hashMap.put("flllag", 1);
							hashMap.put("ycnId", ycnId);
							hashMap.put("ixssId", ixstId);
							List<Replytoclassnotice> replytoclassnotices = ixuestarCloudELMapper.getReplytoclassnotices(hashMap);
							if (replytoclassnotices.size()==0) {
								issuenoticeObject.put("icheck", 2);
							}else {
								Replytoclassnotice replytoclassnotice = replytoclassnotices.get(0);
								String yrcnId = replytoclassnotice.getYrcnId();
								hashMap.put("lineKey", "yrcnId");
								hashMap.put("lineValue", yrcnId);
								List<Replytoclassfile> replytoclassfiles = ixuestarCloudELMapper.getReplytoclassfiles(hashMap);
								JSONObject replynObject = (JSONObject)JSON.toJSON(replytoclassnotice);
								replynObject.put("replytoclassfiles", replytoclassfiles);
								replyObject.putAll(replynObject);
								issuenoticeObject.put("icheck", 3);
							}
						}
						issuenoticeObject.put("replynotice", replyObject);
						
						jsonArray.add(issuenoticeObject);
					}
				}
			}
			//计算页码
			Integer remainPage = total / pageLimit;
			Integer totalPage = total % pageLimit == 0?remainPage:remainPage+1;
			//结果返回
			jsonObject.put("currentPage", pageIndex);
			jsonObject.put("totalResult", total);
			jsonObject.put("totalPage", totalPage);
			jsonObject.put("limitResult", pageLimit);
			jsonObject.put("dataObject", jsonArray);
		}else {
			hashMap.put("flllag", 1);
			hashMap.put("ixstId", ixstId);
			hashMap.put("ycnFlag", ycnFlag);
			hashMap.put("lineKey", "ixscId");
			hashMap.put("lineValue", ixscId);
			int total = ixuestarCloudELMapper.getYxIcnClassesList(hashMap).size();
			//定义查看的区间
			Integer limitResult = pageLimit;
			Integer firstResult = (pageIndex - 1) * pageLimit;
			hashMap.put("flag", 1);
			hashMap.put("limitResult", limitResult);
			hashMap.put("firstResult", firstResult);
			JSONArray jsonArray = new JSONArray();
			List<YxIcnClass> icnClasses = ixuestarCloudELMapper.getYxIcnClassesList(hashMap);
			for (int i = 0; i < icnClasses.size(); i++) {
				YxIcnClass yxIcnClass = icnClasses.get(i);
				String ycnId = yxIcnClass.getYcnId();
				//获取通告内容
				hashMap.put("lineKey", "ycnId");
				hashMap.put("lineValue", ycnId);
				List<Issueclassnotice> issueclassnotices = ixuestarCloudELMapper.getYxIssueclassnotices(hashMap);
				if (issueclassnotices.size()!=0) {
					Issueclassnotice issueclassnotice = issueclassnotices.get(0);
					hashMap.put("lineKey", "ixstId");
					hashMap.put("lineValue", ixstId);
					List<SchoolTeacher> schoolTeachers = ixuestarCloudELMapper.getSchoolTeachers(hashMap);
					if (schoolTeachers.size()!=0) {
						String ixstName = schoolTeachers.get(0).getIxstName();
						JSONObject issueclassnoticeObject = (JSONObject)JSON.toJSON(issueclassnotice);
						issueclassnoticeObject.put("ixstName", ixstName);
						//获取图片文件
						hashMap.put("lineKey", "ycnId");
						hashMap.put("lineValue", ycnId);
						List<IssueclassFile> issueclassFilesList = ixuestarCloudELMapper.getIssueclassFilesList(hashMap);
						issueclassnoticeObject.put("ycnFileList", issueclassFilesList);
						//获取查看的人数和未查看的人数
						hashMap.put("flag", 1);
						hashMap.put("fllag", 0);
						hashMap.put("flllag", 0);
						hashMap.put("ycnId", ycnId);
						hashMap.put("ixscId", ixscId);
						Integer checkNoticeNum = ixuestarCloudELMapper.getYxChecknoticesInfo(hashMap).size();
						hashMap.put("lineKey", "ixscId");
						hashMap.put("lineValue", ixscId);
						int totalNoticeNum = ixuestarCloudELMapper.getSchoolStudents(hashMap).size();
						issueclassnoticeObject.put("checkNoticeNum", checkNoticeNum);
						issueclassnoticeObject.put("totalNoticeNum", totalNoticeNum);
						jsonArray.add(issueclassnoticeObject);
					}
				}
			}
			//返回参数
			int remainPage = total / limitResult;
			int pageCount = total%limitResult==0?remainPage:remainPage+1;
			jsonObject.put("totalPage", pageCount);
			jsonObject.put("totalResult", total);
			jsonObject.put("dataObject", jsonArray);
			jsonObject.put("currentPage", pageIndex);
			jsonObject.put("limitResult", limitResult);
		}
		return jsonObject;
	}
	
	@Override
	public JSONObject getReplyclassnotice(String ixscId, String ycnId, Integer pageIndex, Integer pageLimit) {
		// TODO Auto-generated method stub
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("fllag", 1);
		hashMap.put("ixscId", ixscId);
		hashMap.put("lineKey", "ycnId");
		hashMap.put("lineValue", ycnId);
		int total = ixuestarCloudELMapper.getReplytoclassnotices(hashMap).size();
		//计算页码
		Integer limitResult = pageLimit;
		Integer firstResult = (pageIndex - 1) * pageLimit;
		hashMap.put("flag", 1);
		hashMap.put("limitResult", limitResult);
		hashMap.put("firstResult", firstResult);
		JSONArray jsonArray = new JSONArray();
		List<Replytoclassnotice> replytoclassnotices = ixuestarCloudELMapper.getReplytoclassnotices(hashMap);
		for (int i = 0; i < replytoclassnotices.size(); i++) {
			Replytoclassnotice replytoclassnotice = replytoclassnotices.get(i);
			//获取文件集合
			String ixssId = replytoclassnotice.getIxssId();
			hashMap.put("lineKey", "ixssId");
			hashMap.put("lineValue", ixssId);
			String ixssName = ixuestarCloudELMapper.getSchoolStudents(hashMap).get(0).getIxssName();
			
			
			String yrcnId = replytoclassnotice.getYrcnId();
			hashMap.put("lineKey", "yrcnId");
			hashMap.put("lineValue", yrcnId);
			List<Replytoclassfile> replytoclassfiles = ixuestarCloudELMapper.getReplytoclassfiles(hashMap);
			//对象
			JSONObject replyObject = (JSONObject)JSON.toJSON(replytoclassnotice);
			replyObject.put("ixssName", ixssName);
			replyObject.put("replyFiles", replytoclassfiles);
			jsonArray.add(replyObject);
		}
		//返回参数
		int remainPage = total / limitResult;
		int pageCount = total%limitResult==0?remainPage:remainPage+1;
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("totalPage", pageCount);
		jsonObject.put("dataObject", jsonArray);
		jsonObject.put("currentPage", pageIndex);
		jsonObject.put("limitResult", limitResult);
		
		return jsonObject;
	}
	
	@Override
	public JSONObject getChecktheNotice(String ixscId, String ycnId) {
		// TODO Auto-generated method stub
		//获取班级所有学生名单
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ixscId");
		hashMap.put("lineValue", ixscId);
		List<Object> totalList = new LinkedList<>();
		List<SchoolStudent> schoolStudents = ixuestarCloudELMapper.getSchoolStudents(hashMap);
		for (int i = 0; i < schoolStudents.size(); i++) {
			String ixssName = schoolStudents.get(i).getIxssName();
			totalList.add(ixssName);
		}
		//获取查看消息的学生信息
		hashMap.put("flag", 1);
		hashMap.put("ycnId", ycnId);
		hashMap.put("ixscId", ixscId);
		List<Object> checkList = new LinkedList<>();
		List<YxChecknotice> yxChecknoticesInfo = ixuestarCloudELMapper.getYxChecknoticesInfo(hashMap);
		for (int i = 0; i < yxChecknoticesInfo.size(); i++) {
			String ixssId = yxChecknoticesInfo.get(i).getIxssId();
			//获取学生信息
			hashMap.put("lineKey", "ixssId");
			hashMap.put("lineValue", ixssId);
			List<SchoolStudent> schoolStudentss = ixuestarCloudELMapper.getSchoolStudents(hashMap);
			if (schoolStudents.size()!=0) {
				String ixssName = schoolStudentss.get(0).getIxssName();
				totalList.remove(ixssName);
				checkList.add(ixssName);
			}
		}
		//获取未查看的
		JSONObject resultObject = new JSONObject();
		resultObject.put("checkNotice", checkList);
		resultObject.put("noCheckNotice", totalList);
		return resultObject;
	}
	
	@Override
	public JSONObject upLoadNoticeFile(MultipartFile multipartFile, String fileName, Integer noticeType) {
		// TODO Auto-generated method stub
		JSONObject jsonObject = null;
		//定义文件路径
		String dirPath = "/tmp/noticeFile/";
//		String dirPath = "E:\\temp\\imgFile\\image";
		//文件转换字节
		try {
			byte[] bytes = multipartFile.getBytes();
			//存储文件
			FileControl.uploadFile(bytes, dirPath, fileName);
			//上传文件七牛云
			String filePath = dirPath + fileName;
			File file = new File(filePath);
			//获取文件大小
			String fileType = "";
//			double yxpSize = Double.parseDouble(String.format("%.2f", (file.length()/1024.0/1024.0)));
			String keyName = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date())+(int)(Math.random()*10);
			//判断文件的名称类型
			if (fileName.contains("pdf")) {
				keyName = keyName + ".pdf";
				fileType = "PDF";
			}else if (fileName.contains("docx")) {
				keyName = keyName + ".docx";
				fileType = "DOCX";
			}else if (fileName.contains("doc")) {
				keyName = keyName + ".doc";
				fileType = "DOC";
			}else if (fileName.contains("jpg")) {
				keyName = keyName + ".jpg";
				fileType = "JPG";
			}else if (fileName.contains("jpeg")) {
				keyName = keyName + ".jpeg";
				fileType = "JPEG";
			}else if (fileName.contains("png")) {
				keyName = keyName + ".png";
				fileType = "PNG";
			}
			//上传
			InputStream fileInputStream = new FileInputStream(file);
			String fileToBase64 = QiniuUpLoad.fileToBase64(fileInputStream);
			String ycfUrl = "https://cdn.travbao.com/" + new QiniuUpLoad().fileUpLoadQiniu(fileToBase64, keyName);
			//写入信息
			String ycfId = "ycf" + new Date().getTime() + (int)(Math.random()*10);
			String ycfCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			//写入文件
			if (noticeType==0) {
				IssueclassFile issueclassFile = new IssueclassFile();
				issueclassFile.setYcfId(ycfId);
				issueclassFile.setYcfName(fileName);
				issueclassFile.setYcfType(fileType);
				issueclassFile.setYcfUrl(ycfCreatetime);
				issueclassFile.setYcfCreatetime(ycfCreatetime);
				issueclassFile.setYcfUrl(ycfUrl);
				ixuestarCloudELMapper.writeYxIssueclassfiles(issueclassFile);
				//转换
				jsonObject = (JSONObject)JSONObject.toJSON(issueclassFile);
			}else if (noticeType==1) {
				Replytoclassfile replytoclassfile = new Replytoclassfile();
				replytoclassfile.setYrcfId(ycfId);
				replytoclassfile.setYrcfName(fileName);
				replytoclassfile.setYrcfType(fileType);
				replytoclassfile.setYrcfUrl(ycfUrl);
				replytoclassfile.setYrcfCreatetime(ycfCreatetime);
				ixuestarCloudELMapper.writeReplytoclassfile(replytoclassfile);
				//转换
				jsonObject = (JSONObject)JSONObject.toJSON(replytoclassfile);
				
			}			
			//删除文件
			FileControl.deleteFile(filePath);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return jsonObject;
	}
	
	@Override
	public Integer deleteIssueclassnotice(String ycnId,String ixstId) {
		// TODO Auto-generated method stub
		Integer code = 0;
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ycnId");
		hashMap.put("lineValue", ycnId);
		List<Issueclassnotice> yxIssueclassnotices = ixuestarCloudELMapper.getYxIssueclassnotices(hashMap);
		if (yxIssueclassnotices.size()!=0) {
			Issueclassnotice issueclassnoticeInfo = yxIssueclassnotices.get(0);
			String ixstId2 = issueclassnoticeInfo.getIxstId();
			if (ixstId2.equals(ixstId)) {
				Issueclassnotice issueclassnotice = new Issueclassnotice();
				issueclassnotice.setYcnId(ycnId);
				issueclassnotice.setYcnStatus(0);
				ixuestarCloudELMapper.updateIssueclassnotice(issueclassnotice);
				//回收打印豆和积分
				Integer ycnType = issueclassnoticeInfo.getYcnType();
				//获取每次的分数和豆的数量
				Integer yitNo = 0;
				if(ycnType==0) {
					yitNo = 2;
				}else if (ycnType==1) {
					yitNo = 3;
				}
				recycleIntegralBean(yitNo, ycnId, ixstId);
			}else {
				code = 2;
			}
		}else {
			code = 1;
		}
		return code;
	}
	
	@Override
	public JSONObject getSigninfortheday(String ixscId) {
		// TODO Auto-generated method stub
		JSONObject jsonObject = new JSONObject();
		//获取班级的总人数
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ixscId");
		hashMap.put("lineValue", ixscId);
		List<SchoolStudent> schoolStudents = ixuestarCloudELMapper.getSchoolStudents(hashMap);
		jsonObject.put("schoolstudents", schoolStudents);
		jsonObject.put("schoolstudentnum", schoolStudents.size());
		//获取绑定的人员信息
		hashMap.put("ywType", "2");
		hashMap.put("lineKey", "ixscId");
		hashMap.put("lineValue", ixscId);
		List<SchoolStudent> bindSchoolStudentInfo = ixuestarCloudELMapper.getBindSchoolStudentInfo(hashMap);
		jsonObject.put("bindschoolstudents", bindSchoolStudentInfo);
		jsonObject.put("bindschoolstudentnum", bindSchoolStudentInfo.size());
		//获取未绑定人员的信息
		List<SchoolStudent> nobindstuList = new LinkedList<SchoolStudent>();
		schoolStudents.stream().forEach(ss -> {
			if (!bindSchoolStudentInfo.contains(ss)) {
				nobindstuList.add(ss);
			}
		});
		jsonObject.put("nobindschoolstudents", nobindstuList);
		jsonObject.put("nobindschoolstudentnum", nobindstuList.size());
		//签到人员的信息
		String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		hashMap.put("flag", 0);
		hashMap.put("ywaType0", "1");
		hashMap.put("ywaType1", "3");
		hashMap.put("ixscId", ixscId);
		hashMap.put("ywaPlayDate", today);
		List<SchoolStudent> clockinschoolStudents = ixuestarCloudELMapper.getSchoolClockinStudents(hashMap);
		jsonObject.put("signinschoolstudents", clockinschoolStudents);
		jsonObject.put("signinschoolstudentnum", clockinschoolStudents.size());
		//未绑定的学生名单
		List<SchoolStudent> nosigninstuList = new LinkedList<SchoolStudent>();
		schoolStudents.stream().forEach(ss -> {
			if (!clockinschoolStudents.contains(ss)) {
				nosigninstuList.add(ss);
			}
		});
		jsonObject.put("nosigninschoolstudents", nosigninstuList);
		jsonObject.put("nosigninschoolstudentnum", nosigninstuList.size());
		return jsonObject;
	}
	
	@Override
	public void updateTeacherPoints(String yirNo, String ixscId, String ixstId, String ixssId, Integer integraltype) {
		// TODO Auto-generated method stub
		//更新老师积分
		Map<String, Object> hashMap = new HashMap<>();
		
		hashMap.put("lineKey", "yirNo");
		hashMap.put("lineValue", yirNo);
		Yxintegralrecord integralrecord = ixuestarCloudELMapper.getIntegralrecord(hashMap);
		if (integralrecord==null) {
			//获取类型实体
			hashMap.put("lineKey", "yitNo");
			hashMap.put("lineValue", integraltype);
			Integraltype integraltypeInfo = ixuestarCloudELMapper.getIntegraltypeInfo(hashMap);
			Integer teaPoints = integraltype==null?0:integraltypeInfo.getYitPoint();
			//查询班主任信息
			YxHeadtPoints headtPoints = ixuestarCloudELMapper.getHeadtPoints(ixstId);
			if (headtPoints==null) {
				//创建信息条
				String yhtpId = "yht" + new Date().getTime() + (int)(Math.random()*10);
				String yhtpCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
				//写入
				YxHeadtPoints yxHeadtPoints = new YxHeadtPoints();
				yxHeadtPoints.setYhtpId(yhtpId);
				yxHeadtPoints.setIxstId(ixstId);
				yxHeadtPoints.setYhtpoints(teaPoints);
				yxHeadtPoints.setYhtpCreatetime(yhtpCreatetime);
				ixuestarCloudELMapper.writeHeadtPoints(yxHeadtPoints);
			}else {
				Integer yhtpoints = headtPoints.getYhtpoints() + teaPoints;
				headtPoints.setYhtpoints(yhtpoints);
				ixuestarCloudELMapper.updateHeadtPoints(headtPoints);
			}
			//写入信息
			String yirId = "yir" + new Date().getTime() + (int)(Math.random()*10);
			String yirCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			Yxintegralrecord yxintegralrecord = new Yxintegralrecord();
			yxintegralrecord.setYirId(yirId);
			yxintegralrecord.setYitNo(integraltype);
			yxintegralrecord.setYirNo(yirNo);
			yxintegralrecord.setIxstId(ixstId);
			yxintegralrecord.setYirCreatetime(yirCreatetime);
			ixuestarCloudELMapper.writeIntegralrecord(yxintegralrecord);
			
			
			//执行班级豆的相关逻辑
			Integer yitBean = integraltypeInfo.getYitBean();
			//首先判断是否存在班级条目
			if (!ixscId.equals("")) {
				if (integraltype==1) {
					Classbean classbeanInfo = ixuestarCloudELMapper.getClassbeanInfo(ixscId);
					if (classbeanInfo==null) {
						//创建相关参数
						Classbean classbean = new Classbean();
						String ycbId = "ycb" + new Date().getTime() + (int)(Math.random()*100);
						String ycbCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
						//初始化
						Integer ycbNumber = yitBean + 200;
						//写入
						classbean.setYcbId(ycbId);
						classbean.setIxscId(ixscId);
						classbean.setYcbNumber(ycbNumber);
						classbean.setYcbCreatetime(ycbCreatetime);
						ixuestarCloudELMapper.writeClassbeanInfo(classbean);
					}else {
						Integer ycbNumber = classbeanInfo.getYcbNumber() + yitBean;
						classbeanInfo.setYcbNumber(ycbNumber);
						ixuestarCloudELMapper.updateClassbeanInfo(classbeanInfo);
					}
					//写入记录
					ClassbeanRecord classbeanRecord = new ClassbeanRecord();
					String ycbrId = "ycbr" + new Date().getTime() + (int)(Math.random()*100);
					String ycbrCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
					
					classbeanRecord.setYcbrId(ycbrId);
					classbeanRecord.setIxscId(ixscId);
					classbeanRecord.setIxssId(ixssId);
					classbeanRecord.setYtoId(ixstId);
					classbeanRecord.setYcbNum(yitBean);
					classbeanRecord.setYcbrCreatetime(ycbrCreatetime);
					ixuestarCloudELMapper.writeClassbeanRecord(classbeanRecord);
				}else {
					//首先查询是否已经积累过
					hashMap.put("ixstId", ixstId);
					hashMap.put("ytbroId", yirNo);
					TeacherBeanRecord teacherBeanRecord = ixuestarCloudELMapper.getTeacherBeanRecord(hashMap);
					if (teacherBeanRecord==null) {
						YxteacherBean yxteacherBeanInfo = ixuestarCloudELMapper.getYxteacherBeanInfo(ixstId);
						if (yxteacherBeanInfo==null) {
							//创建相关参数
							YxteacherBean teacherbean = new YxteacherBean();
							String ytbId = "ytb" + new Date().getTime() + (int)(Math.random()*100);
							String ytbCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
							//初始化
							Integer ytbNumber = yitBean + 20;
							//写入
							teacherbean.setYtbId(ytbId);
							teacherbean.setIxstId(ixstId);
							teacherbean.setYtbNumber(ytbNumber);
							teacherbean.setYtbCreatetime(ytbCreatetime);
							ixuestarCloudELMapper.writeYxteacherBeanInfo(teacherbean);
						}else {
							Integer ytbNumber = yxteacherBeanInfo.getYtbNumber() + yitBean;
							yxteacherBeanInfo.setYtbNumber(ytbNumber);
							ixuestarCloudELMapper.updateYxteacherBeanInfo(yxteacherBeanInfo);
						}
						//写入打印记录
						TeacherBeanRecord teacherBeanRecord2 = new TeacherBeanRecord();
						
						String ytbrId = "ytbr" + new Date().getTime() + (int)(Math.random()*100);
						String ytbrCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
						teacherBeanRecord2.setYtbrId(ytbrId);
						teacherBeanRecord2.setIxstId(ixstId);
						teacherBeanRecord2.setYtbroId(yirNo);
						teacherBeanRecord2.setYtbrNum(yitBean);
						teacherBeanRecord2.setYtbrCreatetime(ytbrCreatetime);
						ixuestarCloudELMapper.writeYxteacherBeanRecord(teacherBeanRecord2);
					}
				}
			}
		}
	}
	
	@Override
	public JSONObject getStudentsForIxscId(String ixscId) {
		// TODO Auto-generated method stub
		//获取班级学生信息列表
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ixscId");
		hashMap.put("lineValue", ixscId);
		List<SchoolStudent> schoolStudents = ixuestarCloudELMapper.getSchoolStudents(hashMap);
		//获取班级的人数
		int classStudentNum = schoolStudents.size();
		//添加到对象中
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("classStudentList", schoolStudents);
		jsonObject.put("classStudentNum", classStudentNum);
		//返回
		return jsonObject;
	}
	
	@Override
	public JSONObject writeExamInfo(String yenName, String yenDate, String ixscId, String yenPoints,
			String yenSubject, String ixstId, Integer yenStatus, JSONArray jsonArray) {
		// TODO Auto-generated method stub
		int code = 0;
		JSONObject resultObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("ixscId", ixscId);
		hashMap.put("ixstId", ixstId);
		int mondayPlus = DateUtil.getMondayPlus();
        Calendar currentDate = Calendar.getInstance();
        currentDate.add(Calendar.DATE, mondayPlus);
		String mondayOFWeek = new SimpleDateFormat("yyyy-MM-dd").format(currentDate.getTime())+" 00:00:00";
		String now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
		hashMap.put("startsDate", mondayOFWeek);
		hashMap.put("stopsDate", now);
		List<YxExamination> examinations = ixuestarCloudELMapper.getExaminations(hashMap);
		if (examinations.size()<2) {
			//首先写入考试基本信息
			String yenId = "yen" + new Date().getTime() + (int)(Math.random()*10);
			String yenCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			YxExamination yxExamination = new YxExamination();
			yxExamination.setYenId(yenId);
			yxExamination.setYenName(yenName);
			yxExamination.setYenDate(yenDate);		
			yxExamination.setIxscId(ixscId);
			yxExamination.setYenSubject(yenSubject);
			yxExamination.setYenPoints(yenPoints);
			yxExamination.setIxstId(ixstId);
			yxExamination.setYenStatus(yenStatus);
			yxExamination.setYenCreatetime(yenCreatetime);
			ixuestarCloudELMapper.writeExaminations(yxExamination);
			//循环写入分数
			List<Yxtestscores> list = JSONArray.parseArray(jsonArray.toJSONString(), Yxtestscores.class);
			Collections.sort(list);
			//写入学生数据
			for (int i = 0; i < list.size(); i++) {
				//获取分数对象
				Yxtestscores yxtestscores = list.get(i);
				//创建id
				String ytsId = "yts" + (new Date().getTime()+i+(int)(Math.random()*100)) + (int)(Math.random()*10) + (int)(Math.random()*10);
				String ytsCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
				yxtestscores.setYtsId(ytsId);
				yxtestscores.setYtsRanking(i+1);
				yxtestscores.setYenId(yenId);
				yxtestscores.setYtsStatus(yenStatus);
				yxtestscores.setYtsCreatetime(ytsCreatetime);
				ixuestarCloudELMapper.writeTestScores(yxtestscores);
			}
			//积分记录
			updateTeacherPoints(yenId, ixscId, ixstId, "", 4);
			//获取写入的数据信息
			resultObject.putAll(getTestScoreInfo(yenId, ixscId, yenStatus));
		}else {
			code =1 ;
		}
		resultObject.put("code", code);
		return resultObject;
	}
	
	@Override
	public JSONObject getTestScoreInfo(String yenId, String ixscId, Integer yenStatus) {
		// TODO Auto-generated method stub
		JSONObject resultObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		//获取成绩信息
		YxExamination yxExaminationInfo = ixuestarCloudELMapper.getYxExaminationInfo(yenId);
		if (yxExaminationInfo!=null) {
			resultObject.put("yxExaminationInfo", yxExaminationInfo);
			if (yenStatus==0) {
				//获取列表
				
				hashMap.put("lineKey", "yenId");
				hashMap.put("lineValue", yenId);
				JSONArray stuArray = new JSONArray();
				List<Yxtestscores> yxtestscoreList = ixuestarCloudELMapper.getYxtestscoreList(hashMap);
				for (int i = 0; i < yxtestscoreList.size(); i++) {
					Yxtestscores yxtestscores = yxtestscoreList.get(i);
					//获取
					String ixssId = yxtestscores.getIxssId();
					hashMap.put("lineKey", "ixssId");
					hashMap.put("lineValue", ixssId);
					String ixssName = ixuestarCloudELMapper.getSchoolStudents(hashMap).get(0).getIxssName();
					JSONObject testObject = (JSONObject)JSONObject.toJSON(yxtestscores);
					testObject.put("ixssName", ixssName);
					stuArray.add(testObject);
				}
				//添加
				resultObject.put("stuScoreList", stuArray);
			}else if (yenStatus==1) {
				//获取分数信息
				Temp scoresavgmaxmin = ixuestarCloudELMapper.getScoresavgmaxmin(yenId);
				resultObject.put("scoresavgmaxmin", scoresavgmaxmin);
				//获取班级学生
				hashMap.put("lineKey", "ixscId");
				hashMap.put("lineValue", ixscId);
				int studentNum = ixuestarCloudELMapper.getSchoolStudents(hashMap).size();
				//获取分数分段
				JSONArray jsonArray = new JSONArray();
				Integer firstScore = 0;
				Integer limitScore = 60;
				hashMap.put("yenId", yenId);
				hashMap.put("firstScore", firstScore);
				hashMap.put("limitScore", limitScore);
				int scoreNum0 = ixuestarCloudELMapper.getYxtestscores(hashMap).size();
				JSONObject scoreObject0 = new JSONObject();
				scoreObject0.put("scoreInterval", "[0~60)");
				scoreObject0.put("scoreNum", scoreNum0);
				scoreObject0.put("scorePro", (String.format("%.2f", scoreNum0*100.00/studentNum))+"%");
				jsonArray.add(scoreObject0);
				// 60~75
				firstScore = 60;
				limitScore = 75;
				hashMap.put("firstScore", firstScore);
				hashMap.put("limitScore", limitScore);
				JSONObject scoreObject1 = new JSONObject();
				int scoreNum1 = ixuestarCloudELMapper.getYxtestscores(hashMap).size();
				scoreObject1.put("scoreInterval", "[60~75)");
				scoreObject1.put("scoreNum", scoreNum1);
				scoreObject1.put("scorePro", (String.format("%.2f", scoreNum1*100.00/studentNum))+"%");
				jsonArray.add(scoreObject1);
				// 75~90
				firstScore = 75;
				limitScore = 90;
				hashMap.put("firstScore", firstScore);
				hashMap.put("limitScore", limitScore);
				JSONObject scoreObject2 = new JSONObject();
				int scoreNum2 = ixuestarCloudELMapper.getYxtestscores(hashMap).size();
				scoreObject2.put("scoreInterval", "[75~90)");
				scoreObject2.put("scoreNum", scoreNum2);
				scoreObject2.put("scorePro", (String.format("%.2f", scoreNum2*100.00/studentNum))+"%");
				jsonArray.add(scoreObject2);
				//90~100
				firstScore = 90;
				limitScore = 101;
				hashMap.put("firstScore", firstScore);
				hashMap.put("limitScore", limitScore);
				JSONObject scoreObject3 = new JSONObject();
				int scoreNum3 = ixuestarCloudELMapper.getYxtestscores(hashMap).size();
				scoreObject3.put("scoreInterval", "[90~100]");
				scoreObject3.put("scoreNum", scoreNum3);
				scoreObject3.put("scorePro", (String.format("%.2f", scoreNum3*100.00/studentNum))+"%");
				jsonArray.add(scoreObject3);
				//添加到结果对象
				resultObject.put("scoreInterval", jsonArray);
				//获取列表
				hashMap.put("fllag", 1);
				hashMap.put("lineKey", "yenId");
				hashMap.put("lineValue", yenId);
				JSONArray stuArray = new JSONArray();
				List<Yxtestscores> yxtestscoreList = ixuestarCloudELMapper.getYxtestscoreList(hashMap);
				for (int i = 0; i < yxtestscoreList.size(); i++) {
					Yxtestscores yxtestscores = yxtestscoreList.get(i);
					//获取
					String ixssId = yxtestscores.getIxssId();
					hashMap.put("lineKey", "ixssId");
					hashMap.put("lineValue", ixssId);
					String ixssName = ixuestarCloudELMapper.getSchoolStudents(hashMap).get(0).getIxssName();
					JSONObject testObject = (JSONObject)JSONObject.toJSON(yxtestscores);
					testObject.put("ixssName", ixssName);
					stuArray.add(testObject);
				}
				//添加
				resultObject.put("stuScoreList", stuArray);
			}
		}
		resultObject.put("code", yenStatus);
		return resultObject;
	}
	
	@Override
	public JSONObject updateTestScoreInfo(String yenId, JSONArray jsonArray, Integer yenStatus) {
		// TODO Auto-generated method stub
		int code = 0;
		JSONObject resultObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		//首先获取考试信息的真实性
		YxExamination yxExaminationInfo = ixuestarCloudELMapper.getYxExaminationInfo(yenId);
		if (yxExaminationInfo!=null) {
			
			String ixstId = yxExaminationInfo.getIxstId();
			String ixscId = yxExaminationInfo.getIxscId();
			
			hashMap.put("ixscId", ixscId);
			hashMap.put("ixstId", ixstId);
			String mondayOFWeek = DateUtil.getWeekStart()+" 00:00:00";
			String now = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
			hashMap.put("startsDate", mondayOFWeek);
			hashMap.put("stopsDate", now);
			List<YxExamination> examinations = ixuestarCloudELMapper.getExaminations(hashMap);
			if(examinations.size()<2) {
				//执行
				//首先更新考试信息状态
				YxExamination yxExamination = new YxExamination();
				yxExamination.setYenId(yenId);
				yxExamination.setYenStatus(yenStatus);
				ixuestarCloudELMapper.updateExaminationInfo(yxExamination);
				//循环获取更改分数名次信息
				List<Yxtestscores> list = JSONArray.parseArray(jsonArray.toJSONString(), Yxtestscores.class);
				Collections.sort(list);
				
				for (int i = 0; i < list.size(); i++) {
					//获取对象
					Yxtestscores yxtestscores = list.get(i);
					//更新名次
					yxtestscores.setYtsRanking(i+1);
					yxtestscores.setYtsStatus(yenStatus);
					ixuestarCloudELMapper.updateTestscoreInfo(yxtestscores);
				}
				//获取返回对象
				resultObject.putAll(getTestScoreInfo(yenId, ixscId, yenStatus));
			}else {
				code = 1;
			}
		}		
		resultObject.put("code", code);
		return resultObject;
	}
	
	@Override
	public JSONObject getYxExaminations(String ixstId, String ixscId, Integer pageIndex, Integer pageLimit) {
		// TODO Auto-generated method stub
		int code = 0;
		JSONObject resultObject = new JSONObject();
		//首先获取页面信息
		Integer firstResult = (pageIndex - 1) * pageLimit;
		Integer limitResult = pageLimit;
		//创建参数容器
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("flag", 1);
		hashMap.put("ixscId", ixscId);
		hashMap.put("ixstId", ixstId);
		//首先获取考试信息总数
		Integer examTotal = ixuestarCloudELMapper.getYxExaminations(hashMap).size();
		hashMap.put("fllag", 1);
		hashMap.put("firstResult", firstResult);
		hashMap.put("limitResult", limitResult);
		List<YxExamination> yxExaminations = ixuestarCloudELMapper.getYxExaminations(hashMap);
		if (yxExaminations.size()>0) {
			code = yxExaminations.get(0).getYenStatus();
		}
		//获取总页数
		Integer remainPage = examTotal / limitResult;
		Integer pageCount = examTotal%limitResult==0?remainPage:remainPage+1;
		//添加
		resultObject.put("code", code);
		resultObject.put("totalExam", examTotal);
		resultObject.put("totalPage", pageCount);
		resultObject.put("currentPage", pageIndex);
		resultObject.put("dataObject", yxExaminations);
		//
		return resultObject;
	}
	
	@Override
	public Integer deleteYxExaminations(String ixstId, String yenId) {
		// TODO Auto-generated method stub
		int code = 0;
		//首先获取一下信息
		YxExamination yxExaminationInfo = ixuestarCloudELMapper.getYxExaminationInfo(yenId);
		if (yxExaminationInfo!=null) {
			String ixstId2 = yxExaminationInfo.getIxstId();
			if (ixstId2.equals(ixstId)) {
				yxExaminationInfo.setYenStatus(-1);
				ixuestarCloudELMapper.updateExaminationInfo(yxExaminationInfo);
				//回收打印豆和积分
				recycleIntegralBean(4, yenId, ixstId);
			}else {
				code = 2;
			}
		}else {
			code = 1;
		}
		return code;
	}
	
	@Override
	public JSONObject getIssueResidueDegree(String ixstId,String ixscId,Integer issType) {
		// TODO Auto-generated method stub
		//首先创建参数容器
		int num = 0;
		Map<String, Object> hashMap = new HashMap<>();
		//首先获取类型
		String tDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		hashMap.put("ixscId", ixscId);
		hashMap.put("ixstId", ixstId);
		hashMap.put("tDate", tDate);
		hashMap.put("flag", 2);
		if (issType==1) {
			//获取通知发布的次数
			hashMap.put("ycnFlag", 0);
			num = ixuestarCloudELMapper.getAllIssueclassnotices(hashMap).size();
		}else if (issType==2) {
			//获取作业发布的次数
			hashMap.put("ycnFlag", 1);
			num = ixuestarCloudELMapper.getAllIssueclassnotices(hashMap).size();
		}else if (issType==3) {
			//获取成绩发布的次数
			int mondayPlus = DateUtil.getMondayPlus();
	        Calendar currentDate = Calendar.getInstance();
	        currentDate.add(Calendar.DATE, mondayPlus);
			String mondayOFWeek = new SimpleDateFormat("yyyy-MM-dd").format(currentDate.getTime())+" 00:00:00";
			String ttDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			
			hashMap.put("ixstId", ixstId);
			hashMap.put("ixscId", ixscId);
			hashMap.put("stopsDate", ttDate);
			hashMap.put("startsDate", mondayOFWeek);
			num = ixuestarCloudELMapper.getExaminations(hashMap).size();
		}
		JSONObject resultObject = new JSONObject();
		resultObject.put("num", num);
		return resultObject;
	}
	
	@Override
	public JSONObject getSubjectList(Integer ysPhases) {
		// TODO Auto-generated method stub
		//获取学科列表
		List<Temp> subjectList = ixuestarCloudELMapper.getSubjectList(ysPhases);
		//获取个数
		JSONObject resultObject = new JSONObject();
		resultObject.put("subjectList", subjectList);
		resultObject.put("subjectNum", subjectList.size());
		return resultObject;
	}
	
	@Override
	public String getSchoolClassName(String ixscId) {
		// TODO Auto-generated method stub
		String ixscName = "";
		//获取班级信息
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ixscId");
		hashMap.put("lineValue", ixscId);
		List<SchoolClass> schoolClasses = ixuestarCloudELMapper.getSchoolClasses(hashMap);
		if (schoolClasses.size()!=0) {
			ixscName = schoolClasses.get(0).getIxscName();
		}
		return ixscName;
	}
	
	@Override
	public Integer getFilePageInteger(String ytoId,Integer ytoDoubleSide,Integer ytoPrintNum) {
		// TODO Auto-generated method stub
		int page = 0;
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ytoId");
		hashMap.put("lineValue", ytoId);
		List<YxOrderFile> orderFile = ixuestarCloudELMapper.getOrderFile(hashMap);
		logger.info("---orderFile-"+orderFile+"------");
		for (int i = 0; i < orderFile.size(); i++) {
			YxOrderFile yxOrderFile = orderFile.get(i);
			String ytfId = yxOrderFile.getYtfId();
			hashMap.put("lineKey", "ytfId");
			hashMap.put("lineValue", ytfId);
			YxFile yxFile = ixuestarCloudELMapper.getYxFile(hashMap);
			if (ytoDoubleSide==0) {
				page = page + yxFile.getYtfPage();
			}else {
				page = page + yxFile.getYtfSheet();
			}
		}
		return ytoPrintNum*page;
	}
	
	@Override
	public JSONObject deleteOrderBean(String ytoId) {
		// TODO Auto-generated method stub
		int code = 0;
		JSONObject resultObject = new JSONObject();
		//首先获取订单信息
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ytoId");
		hashMap.put("lineValue", ytoId);
		Yxtorder yxtorderInfo = ixuestarCloudELMapper.getYxtorderInfo(hashMap);
		if (yxtorderInfo!=null) {
			int ptoPayStatus = yxtorderInfo.getPtoPayStatus();
			int ytoPrintStatus = yxtorderInfo.getYtoPrintStatus();
			if (ptoPayStatus==0) {
				code = 2;
			}else {
				if (ytoPrintStatus==0) {
					//获取订单类型 判断班级 0 班级打印；1 老师自用
					JSONArray classArray = new JSONArray();
					JSONArray teacherArray = new JSONArray();
					//获取老师信息
					//获取老师信息
					hashMap.put("lineKey", "ytoId");
					hashMap.put("lineValue", ytoId);
					YxWxuserOrder orderUserObject = ixuestarCloudELMapper.getOrderUserObject(hashMap);
					if (orderUserObject!=null) {
						String ywId = orderUserObject.getYwId();
						hashMap.put("lineKey", "ywId");
						hashMap.put("lineValue", ywId);
						YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
						if (yxWxuser!=null) {
							String ixstId = yxWxuser.getIxssId();
							
							Integer ytoType = yxtorderInfo.getYtoType();
							if (ytoType==0) {
								//获取订单的班级列表
								hashMap.put("lineKey", "ytoId");
								hashMap.put("lineValue", ytoId);
								List<ClassbeanRecord> classbeanRecordList = ixuestarCloudELMapper.getClassbeanRecordList(hashMap);
								for (int i = 0; i < classbeanRecordList.size(); i++) {
									//获取单个对象
									ClassbeanRecord classbeanRecord = classbeanRecordList.get(i);
									String ixscId = classbeanRecord.getIxscId();
									Integer ycbNum = Math.abs(classbeanRecord.getYcbNum());
									//更新班级豆
									Classbean classbeanInfo = ixuestarCloudELMapper.getClassbeanInfo(ixscId);
									if (classbeanInfo!=null) {
										Integer ycbNumber = ycbNum + classbeanInfo.getYcbNumber();
										classbeanInfo.setYcbNumber(ycbNumber);
										ixuestarCloudELMapper.updateClassbeanInfo(classbeanInfo);
										//写入返还记录
										String ycbrId = "ycbr" + new Date().getTime() + (int)(Math.random()*100);
										String ycbrCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
										ClassbeanRecord classbeanRecord2 = new ClassbeanRecord();
										classbeanRecord2.setYcbrId(ycbrId);
										classbeanRecord2.setIxscId(ixscId);
										classbeanRecord2.setIxssId("-");
										classbeanRecord2.setYtoId(ytoId);
										classbeanRecord2.setYcbNum(ycbNum);
										classbeanRecord2.setYcbrCreatetime(ycbrCreatetime);
										ixuestarCloudELMapper.writeClassbeanRecord(classbeanRecord2);
										//转换
										JSONObject classbeanRecordObject = (JSONObject)JSONObject.toJSON(classbeanRecord2);
										classbeanRecordObject.put("ycbNumber", ycbNumber);
										classArray.add(classbeanRecordObject);
									}
								}	
							}else if (ytoType==1) {
								//获取老师信息
								hashMap.put("ytbroId", ytoId);
								hashMap.put("ixstId", ixstId);
								TeacherBeanRecord teacherBeanRecord = ixuestarCloudELMapper.getTeacherBeanRecord(hashMap);
								if (teacherBeanRecord!=null) {
									Integer ytbrNum = Math.abs(teacherBeanRecord.getYtbrNum());
									YxteacherBean yxteacherBeanInfo = ixuestarCloudELMapper.getYxteacherBeanInfo(ixstId);
									if (yxteacherBeanInfo!=null) {
										Integer ytbNumber = ytbrNum + yxteacherBeanInfo.getYtbNumber();
										yxteacherBeanInfo.setYtbNumber(ytbNumber);
										ixuestarCloudELMapper.updateYxteacherBeanInfo(yxteacherBeanInfo);
										teacherArray.add(teacherBeanRecord);
										//写入打印记录
										TeacherBeanRecord teacherBeanRecord2 = new TeacherBeanRecord();
										
										String ytbrId = "ytbr" + new Date().getTime() + (int)(Math.random()*100);
										String ytbrCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
										teacherBeanRecord2.setYtbrId(ytbrId);
										teacherBeanRecord2.setIxstId(ixstId);
										teacherBeanRecord2.setYtbroId(ytoId);
										teacherBeanRecord2.setYtbrNum(ytbrNum);
										teacherBeanRecord2.setYtbrCreatetime(ytbrCreatetime);
										ixuestarCloudELMapper.writeYxteacherBeanRecord(teacherBeanRecord2);
									}
								}
							}
							//修改订单状态
							hashMap.put("lineKey", "ptoPayStatus");
							hashMap.put("lineValue", 0);
							hashMap.put("ytoId", ytoId);
							ixuestarCloudELMapper.updateOrderStatus(hashMap);
							//返回
							resultObject.put("ytoType", ytoType);
							resultObject.put("classArray", classArray);
							resultObject.put("teacherArray", teacherArray);
						}
					}
				}else {
					code = 3;
				}
			}
		}else {
			code = 1;
		}
		resultObject.put("code", code);
		return resultObject;
	}
	
	@Override
	public void deleteWxuserOrder(String ytoId) {
		// TODO Auto-generated method stub
		ixuestarCloudELMapper.deleteWxuserorder(ytoId);
	}
	
	@Override
	public JSONObject getPrintBean(Integer ytype, JSONArray jsonArray) {
		// TODO Auto-generated method stub
		//判断类型 0班级自用；1老师自用
		List<Object> list = new LinkedList<>();
		if (ytype==0) {
			for (int i = 0; i < jsonArray.size(); i++) {
				String ixscId = jsonArray.getString(i);
				//获取打印豆
				Temp classPrintBean = ixuestarCloudELMapper.getClassPrintBean(ixscId);
				if (classPrintBean==null) {
					Temp temp = new Temp();
					temp.setB(ixscId);
					temp.setC("0");
					classPrintBean = temp;
				}
				list.add(classPrintBean);
			}
		}else if (ytype==1) {
			for (int i = 0; i < jsonArray.size(); i++) {
				String ixstId = jsonArray.getString(i);
				//获取打印豆
				Temp teacherPrintBean = ixuestarCloudELMapper.getTeacherPrintBean(ixstId);
				if (teacherPrintBean==null) {
					Temp temp = new Temp();
					temp.setB(ixstId);
					temp.setC("0");
					teacherPrintBean = temp;
				}
				list.add(teacherPrintBean);
			}
		}
		JSONObject resultObject = new JSONObject();
		resultObject.put("getNum", list.size());
		resultObject.put("printBeanList", list);
		return resultObject;
	}
	
	@Override
	public void recycleIntegralBean(Integer yitNo,String yirNo,String ixstId) {
		// TODO Auto-generated method stub
		//获取每次的分数和豆的数量
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "yitNo");
		hashMap.put("lineValue", yitNo);
		Integraltype integraltypeInfo = ixuestarCloudELMapper.getIntegraltypeInfo(hashMap);
		if (integraltypeInfo!=null) {
			Integer yitBean = integraltypeInfo.getYitBean();
			Integer yitPoint = integraltypeInfo.getYitPoint();
			//回收分数
			YxHeadtPoints headtPoints = ixuestarCloudELMapper.getHeadtPoints(ixstId);
			if (headtPoints!=null) {
				Integer yhtpoints = headtPoints.getYhtpoints() - yitPoint;
				headtPoints.setYhtpoints(yhtpoints);
				ixuestarCloudELMapper.updateHeadtPoints(headtPoints);
				//写入信息
				String yirId = "yir" + new Date().getTime() + (int)(Math.random()*10);
				String yirCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
				Yxintegralrecord yxintegralrecord = new Yxintegralrecord();
				yxintegralrecord.setYirId(yirId);
				yxintegralrecord.setYitNo(-yitNo);
				yxintegralrecord.setYirNo(yirNo);
				yxintegralrecord.setIxstId(ixstId);
				yxintegralrecord.setYirCreatetime(yirCreatetime);
				ixuestarCloudELMapper.writeIntegralrecord(yxintegralrecord);
			}
			//回收打印豆
			YxteacherBean yxteacherBeanInfo = ixuestarCloudELMapper.getYxteacherBeanInfo(ixstId);
			if (yxteacherBeanInfo!=null) {
				Integer c = yxteacherBeanInfo.getYtbNumber() - yitBean;
				yxteacherBeanInfo.setYtbNumber(c);
				ixuestarCloudELMapper.updateYxteacherBeanInfo(yxteacherBeanInfo);
				//写入记录
				TeacherBeanRecord teacherBeanRecord2 = new TeacherBeanRecord();
				
				String ytbrId = "ytbr" + new Date().getTime() + (int)(Math.random()*100);
				String ytbrCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
				teacherBeanRecord2.setYtbrId(ytbrId);
				teacherBeanRecord2.setIxstId(ixstId);
				teacherBeanRecord2.setYtbroId(yirNo);
				teacherBeanRecord2.setYtbrNum(-yitBean);
				teacherBeanRecord2.setYtbrCreatetime(ytbrCreatetime);
				ixuestarCloudELMapper.writeYxteacherBeanRecord(teacherBeanRecord2);
			}
		}
	}
	
	////////////////////////
	/////////云易学终端
	///////////////////////
	
	@Override
	public JSONObject judgePrintStatus(String ytoId,int ytoPrintNum,Integer ytoDoubleSide,JSONArray classList) {
		// TODO Auto-generated method stub
		boolean print = true;
		JSONObject resultObject = new JSONObject();
		//获取订单信息
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ytoId");
		hashMap.put("lineValue", ytoId);
		Integer ytfSheet = 0;
		List<YxOrderFile> orderFile = ixuestarCloudELMapper.getOrderFile(hashMap);
		for (int i = 0; i < orderFile.size(); i++) {
			String ytfId = orderFile.get(i).getYtfId();
			hashMap.put("lineKey", "ytfId");
			hashMap.put("lineValue", ytfId);
			YxFile yxFile = ixuestarCloudELMapper.getYxFile(hashMap);
			if (yxFile!=null) {
				if (ytoDoubleSide==0) {
					ytfSheet = ytfSheet + yxFile.getYtfPage();
				}else {
					ytfSheet = ytfSheet + yxFile.getYtfSheet();
				}
			}
		}
		//获取人数
		List<Object> canlist = new LinkedList<>();
		List<Object> canotlist = new LinkedList<>();
		JSONArray classArray = new JSONArray();
		logger.info("-----"+classList+"--------");
		for (int i = 0; i < classList.size(); i++) {
			JSONObject classObject = new JSONObject();
			String ixscId = classList.getString(i);
			//获取班级人数以及班级豆数量
			hashMap.put("lineKey", "ixscId");
			hashMap.put("lineValue", ixscId);
			Integer ixscPersonNum = Integer.parseInt(ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0).getIxscPersonNum())-1;
			//获取打印的总数量
			Integer totalPage = ixscPersonNum*ytoPrintNum*ytfSheet;
			logger.info("-------totalPage--"+totalPage+"------------");
			//获取班级豆
			Classbean classbeanInfo = ixuestarCloudELMapper.getClassbeanInfo(ixscId);
			logger.info("-------classbeanInfo--"+classbeanInfo+"--------------");
			if (classbeanInfo!=null) {
				Integer ycbNumber = classbeanInfo.getYcbNumber();
				if (ycbNumber<totalPage) {
					print = false;
					canotlist.add(ixscId);
				}else {
					//获取老师信息id
					hashMap.put("lineKey", "ytoId");
					hashMap.put("lineValue", ytoId);
					YxWxuserOrder orderUserObject = ixuestarCloudELMapper.getOrderUserObject(hashMap);
					logger.info("-------orderUserObject--"+orderUserObject+"--------------");
					if (orderUserObject!=null) {
						String ywId = orderUserObject.getYwId();
						hashMap.put("lineKey", "ywId");
						hashMap.put("lineValue", ywId);
						YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
						if (yxWxuser!=null) {
							String ixssId = yxWxuser.getIxssId();
							hashMap.put("ytoId", ytoId);
							hashMap.put("ixstId", ixssId);
							hashMap.put("ixscId", ixscId);
							ClassbeanRecord classbeanRecordInfo = ixuestarCloudELMapper.getClassbeanRecordInfo(hashMap);
							logger.info("--classbeanRecordInfo--"+classbeanRecordInfo+"---");
							if (classbeanRecordInfo==null) {
								//扣除打印豆
								ycbNumber = ycbNumber - totalPage;
								classbeanInfo.setYcbNumber(ycbNumber);
								ixuestarCloudELMapper.updateClassbeanInfo(classbeanInfo);
								//写入扣除记录
								String ycbrId = "ycbr" + new Date().getTime() + (int)(Math.random()*100);
								String ycbrCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
								ClassbeanRecord classbeanRecord = new ClassbeanRecord();
								classbeanRecord.setYcbrId(ycbrId);
								classbeanRecord.setIxscId(ixscId);
								classbeanRecord.setIxssId(ixssId);
								classbeanRecord.setYtoId(ytoId);
								classbeanRecord.setYcbNum(0-totalPage);
								classbeanRecord.setYcbrCreatetime(ycbrCreatetime);
								ixuestarCloudELMapper.writeClassbeanRecord(classbeanRecord);
							}
						}
					}
					canlist.add(ixscId);
					
					hashMap.put("lineKey", "ixscId");
					hashMap.put("lineValue", ixscId);
					SchoolClass schoolClass = ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0);
					if (schoolClass!=null) {
						String ixscName = schoolClass.getIxscName();
						String ixsgId = schoolClass.getIxsgId();
						
						hashMap.put("lineKey", "ixsgId");
						hashMap.put("lineValue", ixsgId);
						String ixsgName = ixuestarCloudELMapper.getSchoolGrades(hashMap).get(0).getIxsgName();
						classObject.put("ixscName", ixscName);
						classObject.put("ixsgName", ixsgName);
						classObject.put("ixscId", ixscId);
						classObject.put("classBean", totalPage);
						classArray.add(classObject);
					}
				}
			}else {
				canotlist.add(ixscId);
			}
		}
		logger.info("-----canList------"+canlist+"------------");
		logger.info("-----canotList----"+canotlist+"--------------");
		resultObject.put("canList", canlist);
		resultObject.put("canotList", canotlist);
		resultObject.put("classArray", classArray);
		resultObject.put("print", print);
		return resultObject;
	}
	
	@Override
	public JSONObject judgeTeacherPrint(String ytoId,Integer ytoDoubleSide,String ywId,Integer ytoPrintNum) {
		// TODO Auto-generated method stub
		int ytbNumber = 0;
		boolean bbStatus = true;
		JSONObject resultObject = new JSONObject();
		//获取老师的信息id
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ytoId");
		hashMap.put("lineValue", ytoId);
//		YxWxuserOrder orderUserObject = ixuestarCloudELMapper.getOrderUserObject(hashMap);
//		if (orderUserObject!=null) {
//			String ywId = orderUserObject.getYwId();
			hashMap.put("lineKey", "ywId");
			hashMap.put("lineValue", ywId);
			YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
			if (yxWxuser!=null) {
				String ixstId = yxWxuser.getIxssId();
				//获取老师的打印豆
				YxteacherBean yxteacherBeanInfo = ixuestarCloudELMapper.getYxteacherBeanInfo(ixstId);
				if (yxteacherBeanInfo!=null) {
					ytbNumber = yxteacherBeanInfo.getYtbNumber();
					//获取总页数
					int page = 0;
					hashMap.put("lineKey", "ytoId");
					hashMap.put("lineValue", ytoId);
					List<YxOrderFile> orderFile = ixuestarCloudELMapper.getOrderFile(hashMap);
					logger.info("---orderFile-"+orderFile+"------");
					for (int i = 0; i < orderFile.size(); i++) {
						YxOrderFile yxOrderFile = orderFile.get(i);
						String ytfId = yxOrderFile.getYtfId();
						hashMap.put("lineKey", "ytfId");
						hashMap.put("lineValue", ytfId);
						YxFile yxFile = ixuestarCloudELMapper.getYxFile(hashMap);
						if (ytoDoubleSide==0) {
							page = page + yxFile.getYtfPage();
						}else {
							page = page + yxFile.getYtfSheet();
						}
					}
					 Integer totalPage = ytoPrintNum*page;
					
					if (ytbNumber<totalPage) {
						bbStatus = false;
					}else {
						hashMap.put("ixstId", ixstId);
						hashMap.put("ytbroId", ytoId);
						TeacherBeanRecord teacherBeanRecord = ixuestarCloudELMapper.getTeacherBeanRecord(hashMap);
						if (teacherBeanRecord==null) {
							ytbNumber = ytbNumber - totalPage;
							yxteacherBeanInfo.setYtbNumber(ytbNumber);
							ixuestarCloudELMapper.updateYxteacherBeanInfo(yxteacherBeanInfo);
							
							//写入打印记录
							TeacherBeanRecord teacherBeanRecord2 = new TeacherBeanRecord();
							
							String ytbrId = "ytbr" + new Date().getTime() + (int)(Math.random()*100);
							String ytbrCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
							teacherBeanRecord2.setYtbrId(ytbrId);
							teacherBeanRecord2.setIxstId(ixstId);
							teacherBeanRecord2.setYtbroId(ytoId);
							teacherBeanRecord2.setYtbrNum(0-totalPage);
							teacherBeanRecord2.setYtbrCreatetime(ytbrCreatetime);
							ixuestarCloudELMapper.writeYxteacherBeanRecord(teacherBeanRecord2);
							resultObject.put("ytbNumber", totalPage);
						}
					}
				}else {
					bbStatus = false;
				}
			}
//		}
		resultObject.put("bbStatus", bbStatus);
		return resultObject;
	}
	
	@Override
	public JSONObject getOrderPrintData(String ytoPrintCode) {
		// TODO Auto-generated method stub
		int code = 0;
		int totalPage = 0;
		JSONObject dataObject = new JSONObject();
		//1、获取订单的类型
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ytoPrintCode");
		hashMap.put("lineValue", ytoPrintCode);
		Yxtorder yxtorderInfo = ixuestarCloudELMapper.getYxtorderInfo(hashMap);
		if (yxtorderInfo!=null) {
			String ytoId = yxtorderInfo.getYtoId();
			//其他信息
			String ytoName = yxtorderInfo.getYtoName();
			int ytoPrintNum = yxtorderInfo.getYtoPrintNum();
			Integer ytoType = yxtorderInfo.getYtoType();
			Integer ytoDoubleSide = yxtorderInfo.getYtoDoubleSide();
			JSONArray fileArray = new JSONArray();
			JSONArray classArray = new JSONArray();
			if (ytoType==0) {
//				JSONObject judgePrintStatus = judgePrintStatus(ytoId);
//				Boolean printInfo = judgePrintStatus.getBoolean("print");
//				if (printInfo) {
//					totalPage = judgePrintStatus.getInteger("totalPage");
					int ytoPrintStatus = yxtorderInfo.getYtoPrintStatus();
					logger.info("---ytoPrintStatus--"+ytoPrintStatus+"------");
					if (ytoPrintStatus==0) {
						//2、通过订单获取文件信息
						hashMap.put("lineKey", "ytoId");
						hashMap.put("lineValue", ytoId);
						List<YxOrderFile> orderFile = ixuestarCloudELMapper.getOrderFile(hashMap);
						for (int i = 0; i < orderFile.size(); i++) {
							YxOrderFile yxOrderFile = orderFile.get(i);
							String ytfId = yxOrderFile.getYtfId();
							hashMap.put("lineKey", "ytfId");
							hashMap.put("lineValue", ytfId);
							YxFile yxFile = ixuestarCloudELMapper.getYxFile(hashMap);
							fileArray.add(yxFile);
						}
//						logger.info("-------fileArray-"+fileArray+"----------");
						try {
							//3、通过订单获取班级信息
							hashMap.put("lineKey", "ytoId");
							hashMap.put("lineValue", ytoId);
							List<YxOrderClass> orderClass = ixuestarCloudELMapper.getOrderClass(hashMap);
//							logger.info("-------orderClass-"+orderClass+"----------");
							for (int i = 0; i < orderClass.size(); i++) {
								YxOrderClass yxOrderClass = orderClass.get(i);
								String ixscId = yxOrderClass.getIxscId();
								hashMap.put("lineKey", "ixscId");
								hashMap.put("lineValue", ixscId);
								SchoolClass schoolClass = ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0);
//								logger.info("-------schoolClass-"+schoolClass+"----------");
								if (schoolClass!=null) {
									String ixscPersonNum = schoolClass.getIxscPersonNum();
									String ixscName = schoolClass.getIxscName();
									String ixsgId = schoolClass.getIxsgId();
									hashMap.put("lineKey", "ixsgId");
									hashMap.put("lineValue", ixsgId);
									SchoolGrade schoolGrade = ixuestarCloudELMapper.getSchoolGrades(hashMap).get(0);
//									logger.info("-------schoolGrade-"+schoolGrade+"----------");
									if (schoolGrade!=null) {
										String ixsgName = schoolGrade.getIxsgName();
										JSONObject jsonObject = new JSONObject();
										jsonObject.put("ixscId", ixscId);
										jsonObject.put("ixsgName", ixsgName);
										jsonObject.put("ixscName", ixscName);
										jsonObject.put("ixscPersonNum", ixscPersonNum);
										classArray.add(jsonObject);
									}
								}
							}
						} catch (Exception e) {
							// TODO: handle exception
							e.printStackTrace();
						}
						logger.info("-------classArray-"+classArray+"----------");
					}else {
						code = 2;
					}
//				}else {
//					code = 3; 
//				}
			}else if (ytoType==1) {
				int ptoPayStatus = yxtorderInfo.getPtoPayStatus();
				logger.info("---ptoPayStatus-"+ptoPayStatus+"------");
				if (ptoPayStatus==1) {
					int ytoPrintStatus = yxtorderInfo.getYtoPrintStatus();
					logger.info("---ytoPrintStatus-"+ytoPrintStatus+"------");
					if (ytoPrintStatus==0) {
//						String ytoId = yxtorderInfo.getYtoId();
						//2、通过订单获取文件信息
						int page = 0;
						hashMap.put("lineKey", "ytoId");
						hashMap.put("lineValue", ytoId);
						List<YxOrderFile> orderFile = ixuestarCloudELMapper.getOrderFile(hashMap);
						logger.info("---orderFile-"+orderFile+"------");
						for (int i = 0; i < orderFile.size(); i++) {
							YxOrderFile yxOrderFile = orderFile.get(i);
							String ytfId = yxOrderFile.getYtfId();
							hashMap.put("lineKey", "ytfId");
							hashMap.put("lineValue", ytfId);
							YxFile yxFile = ixuestarCloudELMapper.getYxFile(hashMap);
							if (ytoDoubleSide==0) {
								page = page + yxFile.getYtfPage();
							}else {
								page = page + yxFile.getYtfSheet();
							}
							fileArray.add(yxFile);
						}
						totalPage = ytoPrintNum*page;
//						JSONObject judgeTeacherPrint = judgeTeacherPrint(ytoId, page);
//						Boolean bbStatus = judgeTeacherPrint.getBoolean("ytbNumber");
//						if (!bbStatus) {
//							code = 4;
//						}
					}else {
						code = 2;
					}
				}else {
					code = 1;
				}
			}
//			if (code==0) {
			//修改订单的状态
//			hashMap.put("lineKey", "ytoPrintStatus");
//			hashMap.put("lineValue", "1");
//			hashMap.put("ytoId", ytoId);
//			ixuestarCloudELMapper.updateOrderStatus(hashMap);

			dataObject.put("totalPage", totalPage);
			dataObject.put("fileArray", fileArray);
			dataObject.put("classArray", classArray);
//			}
			JSONObject orderObject = new JSONObject();
			orderObject.put("ytoId", ytoId);
			orderObject.put("ytoType", ytoType);
			orderObject.put("ytoName", ytoName);
			orderObject.put("ytoDoubleSide", ytoDoubleSide);
			orderObject.put("ytoPrintNum", ytoPrintNum);
			dataObject.put("yxtorderInfo", orderObject);
			logger.info("-----dataObject-"+dataObject+"------");
		}else {
			code = -1;
		}
		dataObject.put("code", code);
		return dataObject;
	}
	
	@Override
	public JSONObject writeMalfunction(String ytoPrintCode, String ixsNo, String ymaMsg) {
		// TODO Auto-generated method stub
		//首先获取订单信息
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ytoPrintCode");
		hashMap.put("lineValue", ytoPrintCode);
		Yxtorder yxtorderInfo = ixuestarCloudELMapper.getYxtorderInfo(hashMap);
		if (yxtorderInfo!=null) {
			String ytoId = yxtorderInfo.getYtoId();
			//然后修改订单的有效性
			hashMap.put("lineKey", "ytoPrintStatus");
			hashMap.put("lineValue", "0");
			hashMap.put("ytoId", ytoId);
			ixuestarCloudELMapper.updateOrderStatus(hashMap);
			//发送短信通知相关人员
			//首先获取老师信息
			hashMap.put("lineKey", "ytoId");
			hashMap.put("lineValue", ytoId);
			YxWxuserOrder orderUserObject = ixuestarCloudELMapper.getOrderUserObject(hashMap);
			if (orderUserObject!=null) {
				String ywId = orderUserObject.getYwId();
				hashMap.put("lineKey", "ywId");
				hashMap.put("lineValue", ywId);
				YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
				if (yxWxuser!=null) {
					String ixstId = yxWxuser.getIxssId();
					String ywTelephone = yxWxuser.getYwTelephone();
					//获取学校 年级 班级 老师信息
					hashMap.put("lineKey", "ixstId");
					hashMap.put("lineValue", ixstId);
					List<SchoolTeacher> schoolTeachers = ixuestarCloudELMapper.getSchoolTeachers(hashMap);
					if (schoolTeachers.size()!=0) {
						String ixstName = schoolTeachers.get(0).getIxstName();
						List<YxTeacherClass> teacherClasses = ixuestarCloudELMapper.getTeacherClasses(hashMap);
						if (teacherClasses.size()!=0) {
							String ixscId = teacherClasses.get(0).getIxscId();
							hashMap.put("lineKey", "ixscId");
							hashMap.put("lineValue", ixscId);
							List<SchoolClass> schoolClasses = ixuestarCloudELMapper.getSchoolClasses(hashMap);
							if (schoolClasses.size()!=0) {
								String ixsgId = schoolClasses.get(0).getIxsgId();
								String ixscName = schoolClasses.get(0).getIxscName();
								hashMap.put("lineKey", "ixsgId");
								hashMap.put("lineValue", ixsgId);
								List<SchoolGrade> schoolGrades = ixuestarCloudELMapper.getSchoolGrades(hashMap);
								if (schoolGrades.size()!=0) {
									String ixsId = schoolGrades.get(0).getIxsId();
									String ixsgName = schoolGrades.get(0).getIxsgName();
									hashMap.put("lineKey", "ixsId");
									hashMap.put("lineValue", ixsId);
									List<School> schoolInfo = ixuestarCloudELMapper.getSchoolInfo(hashMap);
									if (schoolInfo.size()!=0) {
										String ixsName = schoolInfo.get(0).getIxsName();
										String yeType = "0";
										//获取要发送短信的电话
										List<Temp> yxEmailInfo = ixuestarCloudELMapper.getYxEmailInfo(yeType);
										for (int i = 0; i < yxEmailInfo.size(); i++) {
											String b = yxEmailInfo.get(i).getB();
											//发送短信
											try {
												System.out.println("------"+b+"---发送短信-------------");
												MessageUtil.sendMessage(ixsName, ixsgName, ixscName, ixstName, ymaMsg, ywTelephone, b);
											} catch (UnsupportedEncodingException e) {
												// TODO Auto-generated catch block
												e.printStackTrace();
											}
										}
									}
								}
							}
						}
					}
				}
			}
			//写入维修信息
			YxMalfunction yxMalfunction = new YxMalfunction();
			//定义id
			String ymaId = "yma" + new Date().getTime() + (int)(Math.random()*10);
			String ymaCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			yxMalfunction.setYmaId(ymaId);
			yxMalfunction.setIxsNo(ixsNo);
			yxMalfunction.setYmaMsg(ymaMsg);
			yxMalfunction.setYtoPrintCode(ytoPrintCode);
			yxMalfunction.setYmaCreatetime(ymaCreatetime);
			ixuestarCloudELMapper.writeMalfunction(yxMalfunction);
		}
		return null;
	}
	
	@Override
	public void upLoadFileOrder(MultipartFile multipartFile) {
		// TODO Auto-generated method stub
//		String dirPath = "e:\\tmp\\tmpDir";
		String dirPath = "/tmp/tmpDir";
		File file = new File(dirPath);
		if (!file.exists()) {
			file.mkdirs();
		}
		//获取文件的名字
		String originalFilename = multipartFile.getOriginalFilename();
		logger.info("上传文件的名字："+originalFilename);
		//定义文件路径
		String filePath = dirPath + "\\" + originalFilename;
		logger.info("上传文件的存储路径："+filePath);
		//保存文件
		try {
			multipartFile.transferTo(new File(filePath));
			logger.info("保存文件成功");
		} catch (IllegalStateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		File wordFile = new File(filePath);
		//pdf转化
		//首先定义pdf转化的路径
		String pdfPath = "e:\\tmp\\tmpPdf";
//		String pdfPath = "/tmp/tmpPdf";
		File file0 = new File(pdfPath);
		if (!file0.exists()) {
			file0.mkdirs();
		}
		//获取文件的名字
		String originalpdfFilename = originalFilename.replace(".doc", ".pdf");
		logger.info("pdf文件的名字："+originalpdfFilename);
		//定义文件路径
		String pdfFilePath = pdfPath + "\\" + originalpdfFilename;
		logger.info("pdf文件的路径："+pdfFilePath);
		File pdfFile = new File(pdfFilePath);
		//转化
		try {
//			ConvertToPdf.doc2pdf(filePath, pdfFilePath);
			documentConverter.convert(wordFile).to(pdfFile).execute();
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			logger.info("------转化失败------");
		}
		
	}
	
	@Override
	public void updateFileOrderStatus(String ytoPrintCode) {
		// TODO Auto-generated method stub
		//获取订单信息
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ytoPrintCode");
		hashMap.put("lineValue", ytoPrintCode);
		Yxtorder yxtorderInfo = ixuestarCloudELMapper.getYxtorderInfo(hashMap);
		if (yxtorderInfo!=null) {
			String ytoId = yxtorderInfo.getYtoId();
			//修改订单的状态
			hashMap.put("lineKey", "ytoPrintStatus");
			hashMap.put("lineValue", "0");
			hashMap.put("ytoId", ytoId);
			ixuestarCloudELMapper.updateOrderStatus(hashMap);
			
		}
	}
	
	@Override
	public JSONObject updateTeacherbindInfo(String ywId,String ixstId,JSONArray ixscIds) {
		// TODO Auto-generated method stub
		//首先删除数据库中原来的绑定班级信息
		ixuestarCloudELMapper.deleteClassTeacher(ixstId);
		//根据信息重新绑定
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("ywId", ywId);
		jsonObject.put("ixstId", ixstId);
		jsonObject.put("ixscIds", ixscIds);
		JSONObject bindTeacherInfo = bindTeacherInfo(jsonObject);
		//返回信息
		return bindTeacherInfo;
	}
	
	@Override
	public Integer updatePrintInfo(String ytoId, String ytoMachinecode) {
		// TODO Auto-generated method stub
		int code = 0;
		//首先查询订单是否存在
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ytoId");
		hashMap.put("lineValue", ytoId);
		Yxtorder yxtorderInfo = ixuestarCloudELMapper.getYxtorderInfo(hashMap);
		if (yxtorderInfo!=null) {			
			//修改订单的状态
			hashMap.put("lineKey", "ytoPrintStatus");
			hashMap.put("lineValue", "1");
			hashMap.put("ytoId", ytoId);
			ixuestarCloudELMapper.updateOrderStatus(hashMap);
			//写入打印时间和机器编码
			String tNow = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			hashMap.put("lineKey", "ytoPrintingtime");
			hashMap.put("lineValue", tNow);
			ixuestarCloudELMapper.updateOrderStatus(hashMap);
			hashMap.put("lineKey", "ytoMachinecode");
			hashMap.put("lineValue", ytoMachinecode);
			ixuestarCloudELMapper.updateOrderStatus(hashMap);
		}else {
			code = 1;
		}
		return code;
	}
	
	
	////////////云易学小程序家长端开发/////////////////
	@Override
	public JSONObject getWxSessionKeyParent(String code) {
		// TODO Auto-generated method stub
		int co = 0;
		JSONObject jsonObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		String wcName = "ixuestart_cloudelParent";
		//获取微信配置参数
		WechatConfig wechatConfig = ixuestarCloudELMapper.getWechatConfig(wcName);
		if (wechatConfig!=null) {
			String wcAppId = wechatConfig.getWcAppId();
			String wcAppSecret = wechatConfig.getWcAppSecret();
			//获取微信配置信息
			try {
				jsonObject.putAll(GetwxOpenId.getWxSessionKey(code, wcAppId, wcAppSecret));
				//获取openId等信息
				String openid = jsonObject.getString("openid");
				//判断用户是否存在
				hashMap.put("lineKey", "ywOpenId");
				hashMap.put("lineValue", openid);
				YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
				if (yxWxuser==null) {
					co = 1;
				}else {
					String ixssId = yxWxuser.getIxssId();
					if (ixssId==null || ixssId.trim().equals("")) {
						co= 2;
					}else {
						JSONObject stuObject = getSchoolStudentInfo(ixssId);
						//获取班级id
						String ixscId = stuObject.getString("ixscId");
						JSONObject headTeacherInfo = getHeadTeacherInfo(ixscId);
						//获取积分表
						JSONObject yxPonitsObject = new JSONObject();
						YxPoints yxPointsInfo = ixuestarCloudELMapper.getYxPointsInfo(ixssId);
						if (yxPointsInfo!=null) {
							yxPonitsObject.putAll((JSONObject)JSON.toJSON(yxPointsInfo));
						}else {
							yxPonitsObject.put("yspoints", 0);
							yxPonitsObject.put("ixssId", ixssId);
						}
						
						//获取写入的次数
						String ywaPlayDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
						hashMap.put("ywId", openid);
						hashMap.put("ywaPlayDate", ywaPlayDate);
						hashMap.put("ywaType", "2");
						List<YxWatchAds> watchAdsInfo = ixuestarCloudELMapper.getWatchAdsInfo(hashMap);
						yxPonitsObject.put("residueDegree", 3-watchAdsInfo.size());
						jsonObject.put("studentInfo", stuObject);
						jsonObject.put("pointsInfo", yxPonitsObject);
						jsonObject.put("headTeacherInfo", headTeacherInfo);
						jsonObject.put("wxUserinfo", (JSONObject)JSONObject.toJSON(yxWxuser));
					}
				}
				//获取连续签到的天数
				Integer numberofcheckins = getNumberofcheckins(openid);
				jsonObject.put("numberofcheckins", numberofcheckins);
				//当天抽奖次数
				Integer num = 0;
				String tDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
				hashMap.put("lineKey", "ywOpenId");
				hashMap.put("lineValue", openid);
				YxWxuser yxWxuser2 = ixuestarCloudELMapper.getYxWxuser(hashMap);
				if (yxWxuser2!=null) {
					String ywId2 = yxWxuser2.getYwId();
					hashMap.put("ywId", ywId2);
					hashMap.put("tDate", tDate);
					num = ixuestarCloudELMapper.getYxLotteryRecords(hashMap).size();
				}
				logger.info("---------num-"+num+"--------------");
				Integer residuedegree = 0;
				if (numberofcheckins==7) {
					residuedegree = (3-num)<0?0:(3-num);
				}
				jsonObject.put("residuedegree", residuedegree);
				jsonObject.put("code", co);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		logger.info("-----------getWxSessionKeyParent-"+jsonObject+"--------------");
		return jsonObject;
	}
	
	@Override
	public JSONObject getWxUserParentInfo(JSONObject jsonObject) {
		// TODO Auto-generated method stub
		int code = 0;
		JSONObject resultObject = new JSONObject();
		//获取openId
		String ywOpenId = jsonObject.getString("openId");
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ywOpenId");
		hashMap.put("lineValue", ywOpenId);
		//通过传递的openId查询是否存在此用户
		YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
		//如果不存在,则首先解析出用户的手机号，将openId一起存储在数据表里
		if (yxWxuser==null) {
			//首先解析出手机号
			//解析老师手机号
			String wxIv = jsonObject.getString("wxIv");
			String wxSessionKey = jsonObject.getString("wxSessionKey");
			String encryptedData = jsonObject.getString("encryptedData");
			JSONObject wxTelephone = GetwxOpenId.getWxTelephone(encryptedData, wxSessionKey, wxIv);
			String ywTelephone = "";
			if (wxTelephone.containsKey("phoneNumber")) {
				ywTelephone = wxTelephone.getString("phoneNumber");
			}
			YxWxuser yxWxuser2 = new YxWxuser();
			//创建ywId
			String ywId = "yw" + new Date().getTime() + (int)(Math.random()*10);
			//
			String ywImgUrl = "https://cdn.travbao.com/WechatIMG70.png";
			//创建时间
			String ywCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			yxWxuser2.setYwId(ywId);
			yxWxuser2.setYwOpenId(ywOpenId);
			yxWxuser2.setYwImgUrl(ywImgUrl);
			yxWxuser2.setYwTelephone(ywTelephone);
			yxWxuser2.setYwCreatetime(ywCreatetime);
			yxWxuser2.setYwType("2");
			yxWxuser2.setIxssId(null);
			ixuestarCloudELMapper.writeYxWxuser(yxWxuser2);	
			code = 1;
			//添加返回结果
			resultObject.put("wxUserinfo", (JSONObject)JSONObject.toJSON(yxWxuser2));
			//获取积分表
			JSONObject yxPonitsObject = new JSONObject();
			yxPonitsObject.put("yspoints", 0);
			yxPonitsObject.put("ixssId", null);
			//获取写入的次数
			String ywaPlayDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
			hashMap.put("ywId", ywOpenId);
			hashMap.put("ywaPlayDate", ywaPlayDate);
			hashMap.put("ywaType", "2");
			List<YxWatchAds> watchAdsInfo = ixuestarCloudELMapper.getWatchAdsInfo(hashMap);
			yxPonitsObject.put("residueDegree", 3-watchAdsInfo.size());
			resultObject.put("pointsInfo", yxPonitsObject);
		}else {
			resultObject.put("wxUserinfo", (JSONObject)JSONObject.toJSON(yxWxuser));
			//如果存在，则查询用户信息是否绑定学生信息
			String ixssId = yxWxuser.getIxssId();
			//如果没有绑定，则提示用户去绑定信息
			JSONObject stuObject = null;
			JSONObject headTeacherInfo = null;
			if (ixssId==null) {
				code = 1;
				//获取积分表
				JSONObject yxPonitsObject = new JSONObject();
				yxPonitsObject.put("yspoints", 0);
				yxPonitsObject.put("ixssId", null);
				//获取写入的次数
				String ywaPlayDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
				hashMap.put("ywId", ywOpenId);
				hashMap.put("ywaPlayDate", ywaPlayDate);
				hashMap.put("ywaType", "2");
				List<YxWatchAds> watchAdsInfo = ixuestarCloudELMapper.getWatchAdsInfo(hashMap);
				yxPonitsObject.put("residueDegree", 3-watchAdsInfo.size());
				resultObject.put("pointsInfo", yxPonitsObject);
			}else { //如果绑定，则查询出相关信息反馈给用户
				stuObject = getSchoolStudentInfo(ixssId);
				//获取班级id
				String ixscId = stuObject.getString("ixscId");
				headTeacherInfo = getHeadTeacherInfo(ixscId);
				//获取积分表
				JSONObject yxPonitsObject = new JSONObject();
				YxPoints yxPointsInfo = ixuestarCloudELMapper.getYxPointsInfo(ixssId);
				if (yxPointsInfo!=null) {
					yxPonitsObject.putAll((JSONObject)JSON.toJSON(yxPointsInfo));
				}else {
					yxPonitsObject.put("yspoints", 0);
					yxPonitsObject.put("ixssId", ixssId);
				}
				
				//获取写入的次数
				String ywaPlayDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
				hashMap.put("ywId", ywOpenId);
				hashMap.put("ywaPlayDate", ywaPlayDate);
				hashMap.put("ywaType", "2");
				List<YxWatchAds> watchAdsInfo = ixuestarCloudELMapper.getWatchAdsInfo(hashMap);
				yxPonitsObject.put("residueDegree", 3-watchAdsInfo.size());
				resultObject.put("pointsInfo", yxPonitsObject);
			}
			resultObject.put("studentInfo", stuObject);
			resultObject.put("headTeacherInfo", headTeacherInfo);
		}
		//获取连续签到的天数
		Integer numberofcheckins = getNumberofcheckins(ywOpenId);
		jsonObject.put("numberofcheckins", numberofcheckins);
		//当天抽奖次数
		Integer num = 0;
		String tDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		hashMap.put("lineKey", "ywOpenId");
		hashMap.put("lineValue", ywOpenId);
		YxWxuser yxWxuser2 = ixuestarCloudELMapper.getYxWxuser(hashMap);
		if (yxWxuser2!=null) {
			String ywId2 = yxWxuser2.getYwId();
			hashMap.put("ywId", ywId2);
			hashMap.put("tDate", tDate);
			num = ixuestarCloudELMapper.getYxLotteryRecords(hashMap).size();
		}
		Integer residuedegree = 0;
		if (numberofcheckins==7) {
			residuedegree = (3-num)<0?0:(3-num);
		}
		jsonObject.put("residuedegree", residuedegree);
		resultObject.put("code", code);
		return resultObject;
	}
	
	@Override
	public JSONObject getSchoolStudentInfo(String ixssId) {
		// TODO Auto-generated method stub
		JSONObject stuObject = new JSONObject();
		//获取学生姓名信息
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ixssId");
		hashMap.put("lineValue", ixssId);
		List<SchoolStudent> schoolStudents = ixuestarCloudELMapper.getSchoolStudents(hashMap);
		if (!schoolStudents.isEmpty()) {
			SchoolStudent schoolStudent = schoolStudents.get(0);
			String ixssName = schoolStudent.getIxssName();
			stuObject.put("ixssId", ixssId);
			stuObject.put("ixssName", ixssName);
			//获取班级信息
			String ixscId = schoolStudent.getIxscId();
			hashMap.put("lineKey", "ixscId");
			hashMap.put("lineValue", ixscId);
			SchoolClass schoolClass = ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0);
			String ixscName = schoolClass.getIxscName();
			stuObject.put("ixscId", ixscId);
			stuObject.put("ixscName", ixscName);
			//获取年级信息
			String ixsgId = schoolClass.getIxsgId();
			hashMap.put("lineKey", "ixsgId");
			hashMap.put("lineValue", ixsgId);
			SchoolGrade schoolGrade = ixuestarCloudELMapper.getSchoolGrades(hashMap).get(0);
			String ixsgName = schoolGrade.getIxsgName();
			stuObject.put("ixsgId", ixsgId);
			stuObject.put("ixsgName", ixsgName);
			//获取学校信息
			String ixsId = schoolGrade.getIxsId();
			hashMap.put("flag", 1);
			hashMap.put("lineKey", "ixsId");
			hashMap.put("lineValue", ixsId);
			School school = ixuestarCloudELMapper.getSchoolInfo(hashMap).get(0);
			String ixsName = school.getIxsName();
			stuObject.put("ixsId", ixsId);
			stuObject.put("ixsName", ixsName);
		}
		return stuObject;
	}
	
	@Override
	public JSONObject getHeadTeacherInfo(String ixscId) {
		// TODO Auto-generated method stub
		JSONObject jsonObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ixscId");
		hashMap.put("lineValue", ixscId);
		YxHeadTeacher yxHeadTeacherInfo = ixuestarCloudELMapper.getYxHeadTeacherInfo(hashMap);
		if (yxHeadTeacherInfo!=null) {
			String ixstId = yxHeadTeacherInfo.getIxstId();
			//获取老师姓名
			hashMap.put("lineKey", "ixstId");
			hashMap.put("lineValue", ixstId);
			List<SchoolTeacher> schoolTeachers = ixuestarCloudELMapper.getSchoolTeachers(hashMap);
			if (schoolTeachers.size()!=0) {
				String ixstName = schoolTeachers.get(0).getIxstName();
				//获取名称
				jsonObject.put("ixstName", ixstName);
			}
			hashMap.put("lineKey", "ixssId");
			hashMap.put("lineValue", ixstId);
			YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
			if (yxWxuser!=null) {
				String ywTelephone = yxWxuser.getYwTelephone();
				jsonObject.put("ywTelephone", ywTelephone);
			}
		}
		return jsonObject;
	}
	
	@Override
	public JSONObject getSchoolStudentList(JSONObject jsonObject) {
		// TODO Auto-generated method stub
		JSONObject stuObject = new JSONObject();
		//首先获取参数 获取班级下的学生名单
		String ixscId = jsonObject.getString("ixscId");
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ixscId");
		hashMap.put("lineValue", ixscId);
		List<SchoolStudent> schoolStudents = ixuestarCloudELMapper.getSchoolStudents(hashMap);
		if (!schoolStudents.isEmpty()) {
			stuObject.put("schoolStudentsList", schoolStudents);
			stuObject.put("schoolStudentsNum", schoolStudents.size());
		}
		return stuObject;
	}
	
	@Override
	public JSONObject bindStudentInfo(String ywId, String ixssId) {
		// TODO Auto-generated method stub
		JSONObject resultObject = new JSONObject();
		int code = 0;
		//首先判断是否存在用户和学生信息是否绑定
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ywId");
		hashMap.put("lineValue", ywId);
		YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
		if (yxWxuser!=null) {
			String ixssId2 = yxWxuser.getIxssId();
			//如果未绑定 则进行绑定 并获取学生信息
			if (ixssId2==null) {
				yxWxuser.setIxssId(ixssId);
				ixuestarCloudELMapper.updateYxWxuser(yxWxuser);
				//如果已经绑定 提示不能重复绑定，并获取学生信息
			}else {
				code = 2;
			}
			//获取积分表
			JSONObject yxPonitsObject = new JSONObject();
			YxPoints yxPointsInfo = ixuestarCloudELMapper.getYxPointsInfo(ixssId);
			if (yxPointsInfo!=null) {
				yxPonitsObject.putAll((JSONObject)JSON.toJSON(yxPointsInfo));
			}else {
				yxPonitsObject.put("yspoints", 0);
				yxPonitsObject.put("ixssId", ixssId);
			}
			//获取写入的次数
			String ywaPlayDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
			hashMap.put("ywId", yxWxuser.getYwOpenId());
			hashMap.put("ywaPlayDate", ywaPlayDate);
			hashMap.put("ywaType", "2");
			List<YxWatchAds> watchAdsInfo = ixuestarCloudELMapper.getWatchAdsInfo(hashMap);
			yxPonitsObject.put("residueDegree", 3-watchAdsInfo.size());
			resultObject.put("pointsInfo", yxPonitsObject);
			//添加微信信息
			resultObject.put("wxUserinfo", (JSONObject)JSONObject.toJSON(yxWxuser));
			//获取学生信息
			JSONObject schoolStudentInfo = getSchoolStudentInfo(ixssId);
			resultObject.put("studentInfo", schoolStudentInfo);
		}else {			
			code = 1;				
		}
		resultObject.put("code", code);
		return resultObject;
	}
	
	@Override
	public JSONObject rebindStudentInfo(String ywId, String ixssId) {
		// TODO Auto-generated method stub
		JSONObject resultObject = new JSONObject();
		int code = 0;
		//首先判断是否存在用户和学生信息是否绑定
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ywId");
		hashMap.put("lineValue", ywId);
		YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
		if (yxWxuser!=null) {
			String ixssId2 = yxWxuser.getIxssId();
			//如果未绑定 则进行绑定 并获取学生信息
			if (ixssId2==null) {
				yxWxuser.setIxssId(ixssId);
				ixuestarCloudELMapper.updateYxWxuser(yxWxuser);
				//如果已经绑定 提示不能重复绑定，并获取学生信息
			}else {
				yxWxuser.setIxssId(ixssId);
				ixuestarCloudELMapper.updateYxWxuser(yxWxuser);
			}
			//获取积分表
			JSONObject yxPonitsObject = new JSONObject();
			YxPoints yxPointsInfo = ixuestarCloudELMapper.getYxPointsInfo(ixssId);
			if (yxPointsInfo!=null) {
				yxPonitsObject.putAll((JSONObject)JSON.toJSON(yxPointsInfo));
			}else {
				yxPonitsObject.put("yspoints", 0);
				yxPonitsObject.put("ixssId", ixssId);
			}
			//获取写入的次数
			String ywaPlayDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
			hashMap.put("ywId", yxWxuser.getYwOpenId());
			hashMap.put("ywaPlayDate", ywaPlayDate);
			hashMap.put("ywaType", "2");
			List<YxWatchAds> watchAdsInfo = ixuestarCloudELMapper.getWatchAdsInfo(hashMap);
			yxPonitsObject.put("residueDegree", 3-watchAdsInfo.size());
			resultObject.put("pointsInfo", yxPonitsObject);
			//添加微信信息
			resultObject.put("wxUserinfo", (JSONObject)JSONObject.toJSON(yxWxuser));
			//获取学生信息
			JSONObject schoolStudentInfo = getSchoolStudentInfo(ixssId);
			resultObject.put("studentInfo", schoolStudentInfo);
		}else {			
			code = 1;				
		}
		resultObject.put("code", code);
		return resultObject;
	}
	
	@Override
	public JSONObject getClassFileOrderPrintList(String ixscId, Integer pageIndex, Integer pageLimit, Integer listType) {
		// TODO Auto-generated method stub
		JSONObject jsonObject = new JSONObject();
		//首先获取订单关系列表
		Map<String, Object> hashMap = new HashMap<>();
		if (listType==0) {
			hashMap.put("flag", 0);
		}else if(listType==1) {
			hashMap.put("flag", 1);
			hashMap.put("ytoPrintStatus", 0);
		}else if (listType==2) {
			hashMap.put("flag", 1);
			hashMap.put("ytoPrintStatus", 1);
		}
		//定义页码相关参数信息
		Integer limitResult = pageLimit;
		Integer firstResult = (pageIndex - 1) * pageLimit;
		hashMap.put("firstResult", firstResult);
		hashMap.put("limitResult", limitResult);
		//获取班级信息id
		JSONArray orderArray = new JSONArray();
		hashMap.put("lineKey", "ixscId");
		hashMap.put("lineValue", ixscId);
		List<YxOrderClass> orderClass = ixuestarCloudELMapper.getYxOrderClasses(hashMap);
		for (int i = 0; i < orderClass.size(); i++) {
			JSONObject orderObject = new JSONObject();
			//获取单个关系对象
			YxOrderClass yxOrderClass = orderClass.get(i);
			//获取订单列表和科目信息
			String ytoId = yxOrderClass.getYtoId();
			hashMap.put("lineKey", "ytoId");
			hashMap.put("lineValue", ytoId);
			Yxtorder yxtorderInfo = ixuestarCloudELMapper.getYxtorderInfo(hashMap);
			//获取信息
			orderObject.put("ytoId", ytoId);
			String ytoName = yxtorderInfo.getYtoName();
			orderObject.put("ytoName", ytoName);
			Integer ytoType = yxtorderInfo.getYtoType();
			String ytType = ytoType==0?"班级分发":"自用";
			orderObject.put("ytoType", ytType);
			int ytoPrintStatus = yxtorderInfo.getYtoPrintStatus();
			String ytPrintStatus = ytoPrintStatus==0?"未完成":"已完成";
			orderObject.put("ytoPrintStatus", ytPrintStatus);
			String ytoCreatetime = yxtorderInfo.getYtoCreatetime();
			orderObject.put("ytoCreatetime", ytoCreatetime);
			//获取班级列表
			JSONArray classArray = new JSONArray();
			List<YxOrderClass> orderClass2 = ixuestarCloudELMapper.getOrderClass(hashMap);
			for (int j = 0; j < orderClass2.size(); j++) {
				JSONObject classObject = new JSONObject();
				//获取单个关系对象 
				YxOrderClass yxOrderClass2 = orderClass2.get(j);
				String ixscId2 = yxOrderClass2.getIxscId();
				classObject.put("ixscId", ixscId2);
				hashMap.put("lineKey", "ixscId");
				hashMap.put("lineValue", ixscId2);
				SchoolClass schoolClass = ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0);
				String ixscName = schoolClass.getIxscName();
				classObject.put("ixscName", ixscName);
				String ixsgId = schoolClass.getIxsgId();
				classObject.put("ixsgId", ixsgId);
				hashMap.put("lineKey", "ixsgId");
				hashMap.put("lineValue", ixsgId);
				String ixsgName = ixuestarCloudELMapper.getSchoolGrades(hashMap).get(0).getIxsgName();
				classObject.put("ixsgName", ixsgName);
				classArray.add(classObject);
			}
			orderObject.put("classList", classArray);
			//获取订单列表
			String ixsId = yxOrderClass.getIxsId();
			hashMap.put("lineKey", "ixsId");
			hashMap.put("lineValue", ixsId);
			String ixsName = ixuestarCloudELMapper.getSubjectInfo(hashMap).getIxsName();
			orderObject.put("ixsName", ixsName);
			orderArray.add(orderObject);
		}
		//获取总条数
		int totalSize = orderClass.size();
		int remainPage = totalSize / pageLimit;
		int totalPage = totalSize % pageLimit == 0 ? remainPage:remainPage+1;
		jsonObject.put("currentPage", pageIndex);
		jsonObject.put("totalPage", totalPage);
		jsonObject.put("totalSize", totalSize);
		jsonObject.put("dataList", orderArray);
		return jsonObject;
	}
	
	@Override
	public JSONObject getFileOrderPrintData(String ytoId) {
		// TODO Auto-generated method stub
		JSONObject printDataObject = new JSONObject();
		int code = 0;
		//获取订单信息
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ytoId");
		hashMap.put("lineValue", ytoId);
		Yxtorder yxtorderInfo = ixuestarCloudELMapper.getYxtorderInfo(hashMap);
		if (yxtorderInfo!=null) {
			String ytoName = yxtorderInfo.getYtoName();
			printDataObject.put("ytoName", ytoName);
			String ytoCreatetime = yxtorderInfo.getYtoCreatetime();
			printDataObject.put("ytoCreatetime", ytoCreatetime);
			String ytoType = yxtorderInfo.getYtoType()==0?"班级分发":"老师自用";
			printDataObject.put("ytoType", ytoType);
			String ytoPrintStatus = yxtorderInfo.getYtoPrintStatus()==0?"未完成":"已完成";
			printDataObject.put("ytoPrintStatus", ytoPrintStatus);
			String ytoDoubleSide = yxtorderInfo.getYtoDoubleSide()==0?"单面打印":"双面打印";
			printDataObject.put("ytoDoubleSide", ytoDoubleSide);
			String ixsName = "";
			//获取订单关联的班级
			JSONArray classArray = new JSONArray();
			List<YxOrderClass> orderClass = ixuestarCloudELMapper.getOrderClass(hashMap);
			for (int i = 0; i < orderClass.size(); i++) {
				JSONObject classObject = new JSONObject();
				//获取单个对象
				YxOrderClass yxOrderClass = orderClass.get(i);
				String ixscId = yxOrderClass.getIxscId();
				classObject.put("ixscId", ixscId);
				//获取班级信息
				hashMap.put("lineKey", "ixscId");
				hashMap.put("lineValue", ixscId);
				SchoolClass schoolClass = ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0);
				String ixscName = schoolClass.getIxscName();
				classObject.put("ixscName", ixscName);
				String ixsgId = schoolClass.getIxsgId();
				classObject.put("ixsgId", ixsgId);				
				//获取年级信息
				hashMap.put("lineKey", "ixsgId");
				hashMap.put("lineValue", ixsgId);
				String ixsgName = ixuestarCloudELMapper.getSchoolGrades(hashMap).get(0).getIxsgName();
				classObject.put("ixsgName", ixsgName);
				classArray.add(classObject);
				//获取科目信息
				String ixsId = yxOrderClass.getIxsId();
				hashMap.put("lineKey", "ixsId");
				hashMap.put("lineValue", ixsId);
				ixsName = ixuestarCloudELMapper.getSubjectInfo(hashMap).getIxsName();
			}
			printDataObject.put("ixsName", ixsName);
			printDataObject.put("classList", classArray);
		}else {
			code = 1;
		}
		printDataObject.put("code", code);
		return printDataObject;
	}
	
	
	
	
	
	@Override
	public JSONObject getYxEduArticles(String ywOpenId) {
		// TODO Auto-generated method stub
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("flag", 0);
		int total = ixuestarCloudELMapper.getYxEduArticles(hashMap).size()-3;
		//获取随机的几条
		int ran = CommonUtil.getRandom(total);
		if (total<3) ran = 0;
		hashMap.put("flag", 1);
		hashMap.put("firstResult", ran);
		hashMap.put("limitResult", 4);
		
		JSONArray jsonArray = new JSONArray();
		//获取文章列表
		List<YxEduArticles> yxEduArticless = ixuestarCloudELMapper.getYxEduArticles(hashMap);
		for (int i = 0; i < yxEduArticless.size(); i++) {
			//获取文章对象
			YxEduArticles yxEduArticles = yxEduArticless.get(i);
			//获取文章对象信息
			String yeaId = yxEduArticles.getYeaId();
			//获取点赞浏览收藏
			YxArticlesComment yxArticlesCommentInfo = ixuestarCloudELMapper.getYxArticlesCommentInfo(yeaId);
			//定义文章的数量
			Integer yacLikes = 0,yacReads = 0,yacCollect = 0;
			if (yxArticlesCommentInfo!=null) {
				yacLikes = yxArticlesCommentInfo.getYacLikes();
				yacReads = yxArticlesCommentInfo.getYacReads();
				yacCollect = yxArticlesCommentInfo.getYacCollect();
			}
			//转换对象
			JSONObject jsonObject = (JSONObject)JSON.toJSON(yxEduArticles);
			jsonObject.put("yacLikes", yacLikes);
			jsonObject.put("yacReads", yacReads);
			jsonObject.put("yacCollect", yacCollect);
			//判断用户是否收藏过点赞过收藏过
			hashMap.put("ywId", ywOpenId);
			hashMap.put("yeaId", yeaId);
			//阅读
			hashMap.put("table", "yx_articlesReadInfo");
			YxArticlesOtherInfo yxArticlesOtherInfos = ixuestarCloudELMapper.getYxArticlesOtherInfos(hashMap);
			if (yxArticlesOtherInfos==null) {
				jsonObject.put("iscReads", 0);
			}else {
				int yalrcStatus = yxArticlesOtherInfos.getYalrcStatus();
				if (yalrcStatus==0) {
					jsonObject.put("iscReads", yalrcStatus);
				}else if (yalrcStatus==1) {
					jsonObject.put("iscReads", yalrcStatus);
				}
			}
			//点赞
			hashMap.put("table", "yx_articlesLikeInfo");
			YxArticlesOtherInfo yxArticlesOtherLikes = ixuestarCloudELMapper.getYxArticlesOtherInfos(hashMap);
			if (yxArticlesOtherLikes==null) {
				jsonObject.put("iscLikes", 0);
			}else {
				int yalrcStatus = yxArticlesOtherLikes.getYalrcStatus();
				if (yalrcStatus==0) {
					jsonObject.put("iscLikes", yalrcStatus);
				}else if (yalrcStatus==1) {
					jsonObject.put("iscLikes", yalrcStatus);
				}
			}
			//收藏
			hashMap.put("table", "yx_articlesCollInfo");
			YxArticlesOtherInfo yxArticlesOtherColls = ixuestarCloudELMapper.getYxArticlesOtherInfos(hashMap);
			if (yxArticlesOtherColls==null) {
				jsonObject.put("iscCollect", 0);
			}else {
				int yalrcStatus = yxArticlesOtherColls.getYalrcStatus();
				if (yalrcStatus==0) {
					jsonObject.put("iscCollect", yalrcStatus);
				}else if (yalrcStatus==1) {
					jsonObject.put("iscCollect", yalrcStatus);
				}
			}
			jsonArray.add(jsonObject);
		}
		//创建
		JSONObject resultObject = new JSONObject();
		resultObject.put("articlesList", jsonArray);
		resultObject.put("articlesNumb", jsonArray.size());
		//返回
		return resultObject;
	}
	
	@Override
	public JSONObject getYxEduArticlesInfo(String yeaId,String ywOpenId) {
		// TODO Auto-generated method stub
		//获取文章对象
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "yeaId");
		hashMap.put("lineValue", yeaId);
		YxEduArticles yxEduArticles = ixuestarCloudELMapper.getYxEduArticlesInfo(hashMap);
		//转换
		JSONObject jsonObject = (JSONObject)JSON.toJSON(yxEduArticles);
		//获取点赞浏览收藏
		YxArticlesComment yxArticlesCommentInfo = ixuestarCloudELMapper.getYxArticlesCommentInfo(yeaId);
		//定义文章的数量
		Integer yacLikes = 0,yacReads = 0,yacCollect = 0;
		if (yxArticlesCommentInfo!=null) {
			yacLikes = yxArticlesCommentInfo.getYacLikes();
			yacReads = yxArticlesCommentInfo.getYacReads();
			yacCollect = yxArticlesCommentInfo.getYacCollect();
		}
		jsonObject.put("yacLikes", yacLikes);
		jsonObject.put("yacReads", yacReads);
		jsonObject.put("yacCollect", yacCollect);
		//判断用户是否收藏过点赞过收藏过
		hashMap.put("ywId", ywOpenId);
		hashMap.put("yeaId", yeaId);
		//阅读
		hashMap.put("table", "yx_articlesReadInfo");
		YxArticlesOtherInfo yxArticlesOtherInfos = ixuestarCloudELMapper.getYxArticlesOtherInfos(hashMap);
		if (yxArticlesOtherInfos==null) {
			jsonObject.put("iscReads", 0);
		}else {
			int yalrcStatus = yxArticlesOtherInfos.getYalrcStatus();
			if (yalrcStatus==0) {
				jsonObject.put("iscReads", yalrcStatus);
			}else if (yalrcStatus==1) {
				jsonObject.put("iscReads", yalrcStatus);
			}
		}
		//点赞
		hashMap.put("table", "yx_articlesLikeInfo");
		YxArticlesOtherInfo yxArticlesOtherLikes = ixuestarCloudELMapper.getYxArticlesOtherInfos(hashMap);
		if (yxArticlesOtherLikes==null) {
			jsonObject.put("iscLikes", 0);
		}else {
			int yalrcStatus = yxArticlesOtherLikes.getYalrcStatus();
			if (yalrcStatus==0) {
				jsonObject.put("iscLikes", yalrcStatus);
			}else if (yalrcStatus==1) {
				jsonObject.put("iscLikes", yalrcStatus);
			}
		}
		//收藏
		hashMap.put("table", "yx_articlesCollInfo");
		YxArticlesOtherInfo yxArticlesOtherColls = ixuestarCloudELMapper.getYxArticlesOtherInfos(hashMap);
		if (yxArticlesOtherColls==null) {
			jsonObject.put("iscCollect", 0);
		}else {
			int yalrcStatus = yxArticlesOtherColls.getYalrcStatus();
			if (yalrcStatus==0) {
				jsonObject.put("iscCollect", yalrcStatus);
			}else if (yalrcStatus==1) {
				jsonObject.put("iscCollect", yalrcStatus);
			}
		}
		return jsonObject;
	}
	
	@Override
	public JSONObject writeWatchAdsInfo(String ywId, Integer ywaType) {
		// TODO Auto-generated method stub
		JSONObject jsonObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		//查询用户是否已经签过到
		String ywaPlayDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		hashMap.put("ywId", ywId);
		hashMap.put("ywaPlayDate", ywaPlayDate);
		if (ywaType==1 || ywaType==3) {
			hashMap.put("ywaType0", 1);
			hashMap.put("ywaType1", 3);
			List<YxWatchAds> watchAdsInfo = ixuestarCloudELMapper.getWatchAdsInfos(hashMap);
			if (watchAdsInfo.size()==0) {
				logger.info("-----执行广告观看插入数据--------");
				//写入信息签到信息
				YxWatchAds yxWatchAds = new YxWatchAds();
				String ywaId = "ywa" + new Date().getTime() + (int)(Math.random()*10);
				String ywaPlaytime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
				yxWatchAds.setYwaId(ywaId);
				yxWatchAds.setYwaType(ywaType);
				yxWatchAds.setYwId(ywId);
				yxWatchAds.setYwaPlaytime(ywaPlaytime);
				ixuestarCloudELMapper.writeWatchAds(yxWatchAds);
				//写入统计表
				JSONObject writeWatchInfo = writeWatchInfo(ywId,ywaType);
				jsonObject.putAll(writeWatchInfo);
			}
		}else if (ywaType==2) {
			hashMap.put("ywaType", ywaType);
			List<YxWatchAds> watchAdsInfo = ixuestarCloudELMapper.getWatchAdsInfo(hashMap);
			if (watchAdsInfo.size() < 3) {
				//写入信息签到信息
				YxWatchAds yxWatchAds = new YxWatchAds();
				String ywaId = "ywa" + new Date().getTime() + (int)(Math.random()*10);
				String ywaPlaytime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
				yxWatchAds.setYwaId(ywaId);
				yxWatchAds.setYwaType(ywaType);
				yxWatchAds.setYwId(ywId);
				yxWatchAds.setYwaPlaytime(ywaPlaytime);
				ixuestarCloudELMapper.writeWatchAds(yxWatchAds);
				//获取ixssId
				hashMap.put("lineKey", "ywOpenId");
				hashMap.put("lineValue", ywId);
				YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
				if (yxWxuser!=null) {
					String ixssId = yxWxuser.getIxssId();
					if (ixssId!=null) {
						//写入积分统计表
						JSONObject writeStuPoints = writeStuPoints(ixssId);	
						jsonObject.put("viewTimes", watchAdsInfo.size()+1);
						jsonObject.putAll(writeStuPoints);
					}
				}
			}else {
				hashMap.put("lineKey", "ywOpenId");
				hashMap.put("lineValue", ywId);
				YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
				if (yxWxuser!=null) {
					String ixssId = yxWxuser.getIxssId();
					if (ixssId!=null) {
						YxPoints yxPointsInfo = ixuestarCloudELMapper.getYxPointsInfo(ixssId);
						JSONObject pointObject = (JSONObject)JSON.toJSON(yxPointsInfo);
						jsonObject.put("viewTimes", 3);
						jsonObject.putAll(pointObject);
					}
				}
			}
		}
		//获取连续签到的天数
		Integer numberofcheckins = getNumberofcheckins(ywId);
		jsonObject.put("numberofcheckins", numberofcheckins);
		//当天抽奖次数
		Integer num = 0;
		String tDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		hashMap.put("lineKey", "ywOpenId");
		hashMap.put("lineValue", ywId);
		YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
		if (yxWxuser!=null) {
			String ywId2 = yxWxuser.getYwId();
			hashMap.put("ywId", ywId2);
			hashMap.put("tDate", tDate);
			num = ixuestarCloudELMapper.getYxLotteryRecords(hashMap).size();
		}
		Integer residuedegree = (3-num)<0?0:(3-num);
		jsonObject.put("residuedegree", residuedegree);
		//返回
		return jsonObject;
	}
	
	@Override
	public JSONObject writeWatchInfo(String ywId, Integer ywaType) {
		// TODO Auto-generated method stub
		Map<String, Object> hashMap = new HashMap<>();
		JSONObject jsonObject = new JSONObject();
		String todayDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		//为点击广告记录班级签到率
		//首先获取签到人员的微信信息并判断是否绑定学生信息
		hashMap.put("lineKey", "ywOpenId");
		hashMap.put("lineValue", ywId);
		YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
		if (yxWxuser!=null) {
			String ixssId = yxWxuser.getIxssId();
			if (ixssId!=null) {
				//如果绑定了 则为该学生所在的班级 计入一次当天的签到
				//获取学生的班级
				hashMap.put("lineKey", "ixssId");
				hashMap.put("lineValue", ixssId);
				SchoolStudent schoolStudent = ixuestarCloudELMapper.getSchoolStudents(hashMap).get(0);
				if (schoolStudent!=null) {
					String ixscId = schoolStudent.getIxscId();
					//获取班级的绑定总人数
					int totalNum = 0;
					//获取绑定人数
					Temp temp = ixuestarCloudELMapper.getClassBindingNum(ixscId);
					if (temp==null) {
						totalNum = 0;
					}else {
						totalNum = Integer.parseInt(temp.getA());
					}
					//判断是否创建了今天的班级记录
					hashMap.put("ixscId", ixscId);
					hashMap.put("ycDate", todayDate);
					YxClassClockin yxClassClockin = ixuestarCloudELMapper.getYxClassClockin(hashMap);
					if (yxClassClockin==null) {
						Integer ycClockin = 1,ycExClockin = 1;
						//如果没有则创建新数据
						YxClassClockin classClockin = new YxClassClockin();
						//计算签到率
						double ycClockinRate = new BigDecimal((float)ycExClockin/totalNum).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
						
						String ycId = "yc" + new Date().getTime() + (int)(Math.random()*10);
						String ycCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
						classClockin.setYcId(ycId);
						classClockin.setYcDate(todayDate);
						classClockin.setIxscId(ixscId);
						classClockin.setYcBinNum(totalNum);
						classClockin.setYcClockin(ycClockin);
						classClockin.setYcExClockin(ycExClockin);
						classClockin.setYcClockinRate(ycClockinRate);
						classClockin.setYcCreatetime(ycCreatetime);
						ixuestarCloudELMapper.writeClassClockIn(classClockin);
						jsonObject.putAll((JSONObject)JSON.toJSON(classClockin));
						//写入老师积分表
						//首先获取老师id并判断老师积分对象是否存在 存在则更新 不存在则创建
						hashMap.put("lineKey", "ixscId");
						hashMap.put("lineValue", ixscId);
						YxHeadTeacher yxHeadTeacherInfo = ixuestarCloudELMapper.getYxHeadTeacherInfo(hashMap);
						if (yxHeadTeacherInfo!=null) {
							String ixstId = yxHeadTeacherInfo.getIxstId();
							//判断是否存在老师积分对象
							updateTeacherPoints("hw"+new Date().getTime(),ixscId,ixstId, ixssId, 1);
						}
					}else {
						JSONObject updateWatchInfo = updateWatchInfo(ywId, todayDate, ixssId, ixscId, totalNum,ywaType);
						jsonObject.putAll(updateWatchInfo);
					}	
					
				}
			}//如果未绑定 则不给与其他操作
		}
		return jsonObject;
	}
	
	@Override
	public JSONObject updateWatchInfo(String ywId,String todayDate,String ixssId,String ixscId,Integer totalNum,Integer ywaType) {
		// TODO Auto-generated method stub
		//更新签到统计表
		Map<String, Object> hashMap = new HashMap<>();
		JSONObject jsonObject = new JSONObject();
		//判断该用户今天是否第一次签到 
		hashMap.put("ywId", ywId);
		hashMap.put("ywaType0", 1);
		hashMap.put("ywaType1", 3);
		hashMap.put("ywaPlayDate", todayDate);
		List<YxWatchAds> watchAdsInfo = ixuestarCloudELMapper.getWatchAdsInfos(hashMap);
		if (watchAdsInfo.size()==1) {
			hashMap.put("ixscId", ixscId);
			hashMap.put("ycDate", todayDate);
			YxClassClockin yxClassClockin = ixuestarCloudELMapper.getYxClassClockin(hashMap);
			//如果有则进行更新
			if (yxClassClockin!=null) {
				hashMap.put("flag", 1);
				hashMap.put("ywaType0", "1");
				hashMap.put("ywaType1", "3");
				hashMap.put("ixscId", ixscId);
				hashMap.put("ywaPlayDate", todayDate);
				Integer ycClockin = ixuestarCloudELMapper.getSchoolClockinStudents(hashMap).size();
				hashMap.put("flag", 0);
				Integer ycExClockin = ixuestarCloudELMapper.getSchoolClockinStudents(hashMap).size();
				logger.info("-----ycClockin-"+ycClockin+"---------ycExClockin-"+ycExClockin+"-------");
				//计算签到率
				double ycClockinRate = new BigDecimal((float)ycExClockin/totalNum).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
				//创建签到表
				yxClassClockin.setYcBinNum(totalNum);
				yxClassClockin.setYcClockin(ycClockin);
				yxClassClockin.setYcExClockin(ycExClockin);
				yxClassClockin.setYcClockinRate(ycClockinRate);
				ixuestarCloudELMapper.updateClassClockIn(yxClassClockin);
				jsonObject.putAll((JSONObject)JSON.toJSON(yxClassClockin));
				//写入老师积分表
				//首先获取老师id并判断老师积分对象是否存在 存在则更新 不存在则创建
				hashMap.put("lineKey", "ixscId");
				hashMap.put("lineValue", ixscId);
				YxHeadTeacher yxHeadTeacherInfo = ixuestarCloudELMapper.getYxHeadTeacherInfo(hashMap);
				if (yxHeadTeacherInfo!=null) {
					String ixstId = yxHeadTeacherInfo.getIxstId();
					//判断是否存在老师积分对象
					updateTeacherPoints("hw"+new Date().getTime(),ixscId,ixstId, ixssId, 1);
				}
			}
		}		
		return jsonObject;
	}
	
	
	@Override
	public JSONObject writeStuPoints(String ixssId) {
		// TODO Auto-generated method stub
		JSONObject jsonObject = new JSONObject();
		//首先获取学生积分信息对象
		YxPoints yxPointsInfo = ixuestarCloudELMapper.getYxPointsInfo(ixssId);
		if (yxPointsInfo!=null) {
			Integer yspoints = yxPointsInfo.getYspoints() + 5;
			yxPointsInfo.setYspoints(yspoints);
			ixuestarCloudELMapper.updateYxPointsInfo(yxPointsInfo);
			jsonObject.putAll((JSONObject)JSON.toJSON(yxPointsInfo));
		}else {
			Integer yspoints = 5;
			String yspId = "ysp" + new Date().getTime() + (int)(Math.random()*10);
			String yspCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			//写入学生积分对象
			YxPoints yxPoints = new YxPoints();
			yxPoints.setYspId(yspId);
			yxPoints.setYspoints(yspoints);
			yxPoints.setIxssId(ixssId);
			yxPoints.setYspCreatetime(yspCreatetime);
			ixuestarCloudELMapper.writeYxPointsInfo(yxPoints);
			jsonObject.putAll((JSONObject)JSON.toJSON(yxPoints));
		}
		return jsonObject;
	}
	
	@Override
	public JSONObject getSchoolInfoBym(JSONObject jsonObject) {
		// TODO Auto-generated method stub
		int code = 0;
		//获取
		String schoolNo = jsonObject.getString("schoolNo");
		//请求
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "yeNo");
		hashMap.put("lineValue", schoolNo);
		YxEquipment maintenanceOFEquipment = ixuestarCloudELMapper.getMaintenanceOFEquipment(hashMap);
		if (maintenanceOFEquipment!=null) {
			jsonObject.putAll((JSONObject)JSONObject.toJSON(maintenanceOFEquipment));			
		}else {
			code = 1;
		}
		jsonObject.put("code", code);
		//返回
		return jsonObject;
	}
	
	@Override
	public JSONObject getYxtorderFiles(String ytoId) {
		// TODO Auto-generated method stub
		JSONObject jsonObject = new JSONObject();
		try {
			//创建集合
			JSONArray jsonArray = new JSONArray();
			Map<String, Object> hashMap = new HashMap<>();
			hashMap.put("lineKey", "ytoId");
			hashMap.put("lineValue", ytoId);
			List<YxOrderFile> orderFile = ixuestarCloudELMapper.getOrderFile(hashMap);
			for (int i = 0; i < orderFile.size(); i++) {
				YxOrderFile yxOrderFile = orderFile.get(i);
				//获取文件id
				String ytfId = yxOrderFile.getYtfId();
				hashMap.put("lineKey", "ytfId");
				hashMap.put("lineValue", ytfId);
				YxFile yxFile = ixuestarCloudELMapper.getYxFile(hashMap);
				yxFile.setYtfUrl("");
				jsonArray.add(yxFile);
			}
			//添加返回
			jsonObject.put("orderFiles", jsonArray);
			jsonObject.put("orderFileNum", jsonArray.size());
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return jsonObject;
	}
	
	@Override
	public boolean getPunchInRate(String ixscId) {
		// TODO Auto-generated method stub
		Date date = new Date();
		//定义是否符合
		boolean isQualified = true;
		//首先获取年级合格率
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ixscId");
		hashMap.put("lineValue", ixscId);
		String ixsgId = ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0).getIxsgId();
		double ypinRate = ixuestarCloudELMapper.getYxRateOfPunchin(ixsgId).getYpinRate();
		//前三个工作日的签到率
		hashMap.put("ixscId", ixscId);
		//获取前一个工作日的签到率
		String date1 = WorkDayCalculateUtils.getDate(date, -1);
		hashMap.put("ycDate", date1);
		YxClassClockin yxClassClockin1 = ixuestarCloudELMapper.getYxClassClockin(hashMap);
		double clockinRate1 = yxClassClockin1==null?0.0:yxClassClockin1.getYcClockinRate();
		//获取前两个工作日的签到率
		String date2 = WorkDayCalculateUtils.getDate(date, -1);
		hashMap.put("ycDate", date2);
		YxClassClockin yxClassClockin2 = ixuestarCloudELMapper.getYxClassClockin(hashMap);
		double clockinRate2 = yxClassClockin2==null?0.0:yxClassClockin2.getYcClockinRate();
		//获取前两个工作日的签到率
		String date3 = WorkDayCalculateUtils.getDate(date, -1);
		hashMap.put("ycDate", date3);
		YxClassClockin yxClassClockin3 = ixuestarCloudELMapper.getYxClassClockin(hashMap);
		double clockinRate3 = yxClassClockin3==null?0.0:yxClassClockin3.getYcClockinRate();
		if (clockinRate1 < ypinRate && clockinRate2 < ypinRate && clockinRate3 < ypinRate) {
			isQualified = false;
		}
		//返回结果
		return isQualified;
	}
	
	@Override
	public JSONObject writeArticlesLikeReadCollect(String ywOpenId, String yeaId, Integer operation,
			Integer operationType) {
		// TODO Auto-generated method stub
		JSONObject jsonObject = new JSONObject();
		//首先获取文章的评论对象
		YxArticlesComment yxArticlesCommentInfo = ixuestarCloudELMapper.getYxArticlesCommentInfo(yeaId);
		//如果没有则进行创建
		if (yxArticlesCommentInfo==null) {
			YxArticlesComment yxArticlesComment = new YxArticlesComment();
			//创建id和时间
			String yacId = "yac" + new Date().getTime() + (int)(Math.random()*10);
			String yacCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			//写入
			yxArticlesComment.setYacId(yacId);
			yxArticlesComment.setYeaId(yeaId);
			yxArticlesComment.setYacLikes(0);
			yxArticlesComment.setYacReads(0);
			yxArticlesComment.setYacCollect(0);
			yxArticlesComment.setYacCreatetime(yacCreatetime);
			ixuestarCloudELMapper.writeYxArticlesCommentInfo(yxArticlesComment);
			//进而更新数据
			JSONObject updateArticlesLikeReadCollect = updateArticlesLikeReadCollect(ywOpenId, yeaId, operation, operationType);
			jsonObject.putAll(updateArticlesLikeReadCollect);
		}else {
			//如果有则进行更新
			JSONObject updateArticlesLikeReadCollect = updateArticlesLikeReadCollect(ywOpenId, yeaId, operation, operationType);
			jsonObject.putAll(updateArticlesLikeReadCollect);
		}
		//然后根据操作类型写入历史记录
		return jsonObject;
	}
	
	@Override
	public JSONObject updateArticlesLikeReadCollect(String ywOpenId, String yeaId, Integer operation,
			Integer operationType) {
		// TODO Auto-generated method stub
		JSONObject jsonObject = new JSONObject();
		//首先获取该文章的评论对象
		YxArticlesComment yxArticlesCommentInfo = ixuestarCloudELMapper.getYxArticlesCommentInfo(yeaId);
		if (yxArticlesCommentInfo!=null) {
			Integer yacReads = yxArticlesCommentInfo.getYacReads();
			Integer	yacLikes = yxArticlesCommentInfo.getYacLikes();
			Integer	yacCollect = yxArticlesCommentInfo.getYacCollect();
			if (operation==0) {
				 yacReads = yacReads + operationType;
			}else if (operation==1) {
				 yacLikes = yacLikes + operationType;
			}else if (operation==2) {
				 yacCollect = yacCollect + operationType;
			}
			//更新数据
			yxArticlesCommentInfo.setYacLikes(yacLikes);
			yxArticlesCommentInfo.setYacReads(yacReads);
			yxArticlesCommentInfo.setYacCollect(yacCollect);
			ixuestarCloudELMapper.updateYxArticlesCommentInfo(yxArticlesCommentInfo);
			//创建或者修改对象
			JSONObject writeArticlesRlc = writeArticlesRlc(ywOpenId, yeaId, operation, operationType);
			//转换对象
			jsonObject.put("rclObject", writeArticlesRlc);
			jsonObject.putAll((JSONObject)JSON.toJSON(yxArticlesCommentInfo));
		}
		return jsonObject;
	}
	
	@Override
	public JSONObject writeArticlesRlc(String ywOpenId, String yeaId, Integer operation, Integer operationType) {
		// TODO Auto-generated method stub
		//创建对象
		Map<String, Object> hashMap = new HashMap<>();
		//判断表
		if (operation==0) {
			hashMap.put("table", "yx_articlesReadInfo");
		}else if (operation==1) {
			hashMap.put("table", "yx_articlesLikeInfo");
		}else if (operation==2) {
			hashMap.put("table", "yx_articlesCollInfo");
		}
		//获取点赞浏览收藏对象
		hashMap.put("lineKey", "yeaId");
		hashMap.put("lineValue", yeaId);
		YxArticlesOtherInfo yxArticlesOtherInfo = ixuestarCloudELMapper.getYxArticlesOtherInfo(hashMap);
		if (yxArticlesOtherInfo!=null) {
			if (operationType==1) {
				hashMap.put("yalrcStatus", 1);
			}else if (operationType==-1)  {
				hashMap.put("yalrcStatus", 0);
			}
			String yalrcId = yxArticlesOtherInfo.getYalrcId();
			hashMap.put("yalrcId", yalrcId);
			hashMap.put("yeaId", yeaId);
			hashMap.put("ywId", ywOpenId);
			String yalrcCreatetime = yxArticlesOtherInfo.getYalrcCreatetime();
			hashMap.put("yalrcCreatetime", yalrcCreatetime);
			ixuestarCloudELMapper.updateYxArticlesOtherInfo(hashMap);
		}else {
			String yalrcId = "yalrc" + new Date().getTime() + (int)(Math.random()*10);
			String yalrcCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			//写入对象
			hashMap.put("yalrcId", yalrcId);
			hashMap.put("yeaId", yeaId);
			hashMap.put("ywId", ywOpenId);
			hashMap.put("yalrcStatus", 1);
			hashMap.put("yalrcCreatetime", yalrcCreatetime);
			ixuestarCloudELMapper.writeYxArticlesOtherInfo(hashMap);
		}
		//hashmap转换jsonObject
		String jsonString = JSON.toJSONString(hashMap);
		JSONObject parseObject = JSONObject.parseObject(jsonString);
		parseObject.remove("table");
		parseObject.remove("lineKey");
		parseObject.remove("lineValue");
		return parseObject;
	}
			
	@Override
	public JSONObject gettingDisplayAds(String ywOpenId, String yasId) {
		// TODO Auto-generated method stub
		//创建容器
		int code = 0;
		JSONObject resultObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		//判断文章id
		if (yasId==null) {
			//对于新用户展示微信广告
			hashMap.put("lineKey", "ywOpenId");
			hashMap.put("lineValue", ywOpenId);
			YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
			if (yxWxuser==null) {
				code = 2;
			}else {
				String ixssId = yxWxuser.getIxssId();
				//判断是否绑定 如果未绑定则继续展示微信广告
				if (ixssId==null) {
					code = 2;
				}else {
					//通过学生id获取学校id
					JSONObject schoolStudentInfo = getSchoolStudentInfo(ixssId);
					if (schoolStudentInfo==null) {
						code = 2;
					}else {
						String ixsId = schoolStudentInfo.getString("ixsId");
						//通过学校id获取广告条目
						Advertisingschool advertisingschool = ixuestarCloudELMapper.getAdvertisingschool(ixsId);
						if (advertisingschool==null) {
							code = 2;
						}else {
							String yaiId = advertisingschool.getYaiId();
							//通过条目获取详细信息
							Advertisingitems advertisingitems = ixuestarCloudELMapper.getAdvertisingitems(yaiId);
							if (advertisingitems==null) {
								code = 2;
							}else {
								Date yaiStartDate=null;
								try {
									yaiStartDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(advertisingitems.getYaiStartDate());
								} catch (ParseException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								}
								Date yaiExpriyDate=null;
								try {
									yaiExpriyDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(advertisingitems.getYaiExpriyDate());
								} catch (ParseException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								}
								Date today = new Date();
								if (yaiStartDate.compareTo(today)<0 && today.compareTo(yaiExpriyDate)<0) {
									List<ProbabilityEntity<String>> probabilityEntityList = new ArrayList<ProbabilityEntity<String>>();
									//获取关联信息
									hashMap.put("lineKey", "yaiId");
									hashMap.put("lineValue", yaiId);
									List<Advertisingassoc> advertisingassocs = ixuestarCloudELMapper.getAdvertisingassocs(hashMap);
									for (int i = 0; i < advertisingassocs.size(); i++) {
										Advertisingassoc advertisingassoc = advertisingassocs.get(i);
										//获取其他信息
										ProbabilityEntity<String> probabilityEntity = new ProbabilityEntity<>();
										
										String yasId2 = advertisingassoc.getYasId();
										probabilityEntity.setId(yasId2);
										String yaaId = advertisingassoc.getYaaId();
										probabilityEntity.setEntity(yaaId);
										double yaaproportion = advertisingassoc.getYaaproportion();
										probabilityEntity.setProbabilityValue(yaaproportion);
										probabilityEntityList.add(probabilityEntity);
									}
									//设置默认广告
									ProbabilityEntity<String> probabilityEntity0 = new ProbabilityEntity<>();
									probabilityEntity0.setId("yas00000000");
									probabilityEntity0.setEntity("微信广告");
									probabilityEntity0.setProbabilityValue(0.0);
									//执行概率获取广告
									ProbabilityEntity<String> probabilityLottery = MyAlgorithmUtil.probabilityLottery(probabilityEntityList, probabilityEntity0);
									//获取返回结果
									String id = probabilityLottery.getId();
									if (id.equals("yas00000000")) {
										code = 2;
									}else {
										JSONArray jsonArray = new JSONArray();
										YxAdvertising yxAdvertisingInfo = ixuestarCloudELMapper.getYxAdvertisingInfo(id);
										//json转换
										JSONObject adverObject = (JSONObject)JSONObject.toJSON(yxAdvertisingInfo);
										//获取广告图片集合
										List<PictureInfo> pictrueInfo = ixuestarCloudELMapper.getPictrueInfo(id);
										adverObject.put("pictureList", pictrueInfo);
										jsonArray.add(adverObject);
										//返回结果
										resultObject.put("advertis", jsonArray);
										resultObject.put("advertisNum", jsonArray.size());
									}
								}else {
									
								}
							}
						}
					}
				}
			}
		} else {
			JSONArray jsonArray = new JSONArray();
			YxAdvertising yxAdvertisingInfo = ixuestarCloudELMapper.getYxAdvertisingInfo(yasId);
			if (yxAdvertisingInfo==null) {
				code = 2;
			}else {
				//获取时间
				String yasStartDate = yxAdvertisingInfo.getYasStartDate();
				Date startDate=null;
				try {
					startDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(yasStartDate);
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				String yasExpiryDate = yxAdvertisingInfo.getYasExpiryDate();
				Date stopDate=null;
				try {
					stopDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(yasExpiryDate);
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				//获取当前时间
				Date date = new Date();
				if (date.compareTo(startDate)<0 || date.compareTo(stopDate)>0) {
					yxAdvertisingInfo.setYasDisplayStatus(0);
					ixuestarCloudELMapper.updateYxAdvertisingInfo(yxAdvertisingInfo);
				}else {
					//json转换
					JSONObject adverObject = (JSONObject)JSONObject.toJSON(yxAdvertisingInfo);
					//获取广告图片集合
					List<PictureInfo> pictrueInfo = ixuestarCloudELMapper.getPictrueInfo(yasId);
					adverObject.put("pictureList", pictrueInfo);
					jsonArray.add(adverObject);
				}
			}
			if (jsonArray.size()==0) {
				code = 2;
			}else {
				resultObject.put("advertis", jsonArray);
				resultObject.put("advertisNum", jsonArray.size());
			}
		}
		resultObject.put("code", code);
		return resultObject;
	}
	
	@Override
	public JSONObject getTenPromotionCode(String ywOpenId,String yasId) {
		// TODO Auto-generated method stub
		//定义抽取状态
		int code = 0;
		String ypcExtractStatus = "0";
		JSONObject jsonObject = new JSONObject();
		//创建map
		Map<String, Object> hashMap = new HashMap<>();
		//首先判断是否领取过
		hashMap.put("yasId", yasId);
		hashMap.put("ywId", ywOpenId);
		YxWxuserCode wxuserCode = ixuestarCloudELMapper.getYxWxuserCode(hashMap);
		if (wxuserCode==null) {
			hashMap.put("flag", 1);
			hashMap.put("lineKey", "ypcExtractStatus");
			hashMap.put("lineValue", ypcExtractStatus);
			YxPromotionCode yxPromotionCode = ixuestarCloudELMapper.getYxPromotionCode(hashMap);
			if (yxPromotionCode!=null) {
				String ypcId = yxPromotionCode.getYpcId();
//				String yasId = yxPromotionCode.getYasId();
				//写入抽取状态
				YxWxuserCode yxWxuserCode = new YxWxuserCode();
				//定义id
				String yucId = "yuc" + new Date().getTime() + (int)(Math.random()*10);
				//定义创建时间
				String yucCReatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
				//写入
				yxWxuserCode.setYucId(yucId);
				yxWxuserCode.setYwId(ywOpenId);
				yxWxuserCode.setYpcId(ypcId);
				yxWxuserCode.setYasId(yasId);
				yxWxuserCode.setYpcUserStatus(0);
				yxWxuserCode.setYucCreatetime(yucCReatetime);
				ixuestarCloudELMapper.writeWxuserPromotionCode(yxWxuserCode);
				//并修改此码的状态
				ypcExtractStatus = "1";
				hashMap.put("ypcId", ypcId);
				hashMap.put("lineKey", "ypcExtractStatus");
				hashMap.put("lineValue", ypcExtractStatus);
				ixuestarCloudELMapper.updateYxPromotionCode(hashMap);
				//加入对象
				jsonObject.put("yxWxuserCode", yxWxuserCode);
				jsonObject.put("yxPromotionCode", yxPromotionCode);
			}else {
				code = 1;
			}
		}else {
			code = 2;
		}
		jsonObject.put("code", code);
		return jsonObject;
	}
	
	@Override
	public JSONObject getPromotionCodeList(String ywOpenId, Integer listType,Integer pageIndex,Integer pageSize) {
		// TODO Auto-generated method stub
		JSONObject jsObject = new JSONObject();
		//创建map
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ywId");
		hashMap.put("lineValue", ywOpenId);
		hashMap.put("ypcUserStatus", listType);
		//定义页码
		Integer firstResult = (pageIndex - 1) * pageSize;
		Integer limitResult = pageSize;
		hashMap.put("firstResult", firstResult);
		hashMap.put("limitResult", limitResult);
		JSONArray jsonArray = new JSONArray();
		List<YxWxuserCode> yxWxuserCodes = ixuestarCloudELMapper.getYxWxuserCodes(hashMap);
		//循环获取
		for (int i = 0; i < yxWxuserCodes.size(); i++) {
			//获取对象
			YxWxuserCode yxWxuserCode = yxWxuserCodes.get(i);
			//获取十位码的详细信息
			String ypcId = yxWxuserCode.getYpcId();
			//获取
			hashMap.put("lineKey", "ypcId");
			hashMap.put("lineValue", ypcId);
			hashMap.put("flag", 0);
			YxPromotionCode yxPromotionCode = ixuestarCloudELMapper.getYxPromotionCode(hashMap);
			//获取品牌id
			String yasId = yxPromotionCode.getYasId();
			YxAdvertising yxAdvertisingInfo = ixuestarCloudELMapper.getYxAdvertisingInfo(yasId);
			if(yxAdvertisingInfo!=null) {
				//转换jsonObject
				JSONObject jsonObject = (JSONObject)JSON.toJSON(yxAdvertisingInfo);
				jsonObject.put("promotionCode", yxPromotionCode);
				jsonArray.add(jsonObject);
			}
		}
		//返回参数
		jsObject.put("promotionList", jsonArray);
		jsObject.put("promotionListNum", jsonArray.size());
		
		return jsObject;
	}
	
	@Override
	public JSONObject getAdverList() {
		// TODO Auto-generated method stub
		List<YxAdvertising> advertisings = ixuestarCloudELMapper.getAdvertisings();
		//返回
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("adverList", advertisings);
		jsonObject.put("adverNum", advertisings.size());
		return jsonObject;
	}
	
	@Override
	public JSONObject upLoadAdverFile(MultipartFile multipartFile,String fileName,String yasId) {
		// TODO Auto-generated method stub
		JSONObject jsonObject = null;
		//定义文件路径
		String dirPath = "/tmp/imgFile/image";
//		String dirPath = "E:\\temp\\imgFile\\image";
		//文件转换字节
		try {
			byte[] bytes = multipartFile.getBytes();
			//存储文件
			FileControl.uploadFile(bytes, dirPath, fileName);
			//上传文件七牛云
			String filePath = dirPath + fileName;
			File file = new File(filePath);
			//获取文件大小
			double yxpSize = Double.parseDouble(String.format("%.2f", (file.length()/1024.0/1024.0)));
			//上传
			InputStream fileInputStream = new FileInputStream(file);
			String fileToBase64 = QiniuUpLoad.fileToBase64(fileInputStream);
			String yxpUrl = "https://cdn.travbao.com/" + new QiniuUpLoad().fileUpLoadQiniu(fileToBase64, fileName);
			//写入信息
			PictureInfo pictureInfo = new PictureInfo();
			//创建id和时间
			String yxpId = "yxp" + new Date().getTime() + (int)(Math.random()*10);
			String yxpCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			pictureInfo.setYxpId(yxpId);
			pictureInfo.setYxpName(fileName);
			pictureInfo.setYxpSize(yxpSize);
			pictureInfo.setYxpUrl(yxpUrl);
			pictureInfo.setYasId(yasId);
			pictureInfo.setYxpCreatetime(yxpCreatetime);
			ixuestarCloudELMapper.writeAdverPicture(pictureInfo);
			//转换json
			jsonObject = (JSONObject)JSONObject.toJSON(pictureInfo);
			//删除文件
			FileControl.deleteFile(filePath);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return jsonObject;
	}
	
	@Override
	public JSONObject getstuClassSchedule(String ixscId) {
		// TODO Auto-generated method stub
		JSONObject resultObject = new JSONObject();
		Integer ywcWeek = 0;
		Integer ywcClass = 0;
		//首先获取是否存在课程表
		Map<String, Object> hashMap = new HashMap<>();
		//首先查询该班级的框架
		hashMap.put("lineKey", "ixscId");
		hashMap.put("lineValue", ixscId);
		SchoolClass schoolClass = ixuestarCloudELMapper.getSchoolClasses(hashMap).get(0);
		if (schoolClass!=null) {
			String ixsgId = schoolClass.getIxsgId();
			
			YxWeeksClass yxWeeksClassInfo = ixuestarCloudELMapper.getYxWeeksClassInfo(ixsgId);
			if (yxWeeksClassInfo!=null) {
				ywcWeek = yxWeeksClassInfo.getYwcWeek();
				ywcClass = yxWeeksClassInfo.getYwcClass();
				resultObject.put("ywcWeek", ywcWeek);
				resultObject.put("ywcClass", ywcClass);
				resultObject.put("classscheduleNum", ywcClass*ywcWeek);
			}
		}
		
		//然后查询出并反馈给前端
		hashMap.put("flag", 0);
		hashMap.put("fllag", 1);
		hashMap.put("ycsStatus", 1);
		hashMap.put("ixscId", ixscId);
		List<YxClassschedule> classscheduless = ixuestarCloudELMapper.getClassschedules(hashMap);
		resultObject.put("classscheduless", classscheduless);
		return resultObject;
	}
	
	@Override
	public JSONObject getClasstoinform(Integer ycnFlag,Integer ycnType, String ixssId, String ixscId, Integer pageIndex, Integer pageLimit) {
		// TODO Auto-generated method stub
		//创建参数容器
		JSONObject resultObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		//获取通知列表
		hashMap.put("flag", 0);
		hashMap.put("fllag", 1);
		hashMap.put("ycnFlag", ycnFlag);
		hashMap.put("ycnType", ycnType);
		hashMap.put("lineKey", "ixscId");
		hashMap.put("lineValue", ixscId);
		int total = ixuestarCloudELMapper.getYxIcnClassesList(hashMap).size();
		//定义页码
		Integer limitResult = pageLimit;
		Integer firstResult = (pageIndex - 1) * pageLimit;
		hashMap.put("flag", 1);
		hashMap.put("fllag", 1);
		hashMap.put("ycnType", ycnType);
		hashMap.put("limitResult", limitResult);
		hashMap.put("firstResult", firstResult);
		//获取
		JSONArray jsonArray = new JSONArray();
		List<YxIcnClass> icnClasses = ixuestarCloudELMapper.getYxIcnClassesList(hashMap);
		for (int i = 0; i < icnClasses.size(); i++) {
			YxIcnClass yxIcnClass = icnClasses.get(i);
			//获取通知id
			String ycnId = yxIcnClass.getYcnId();
			hashMap.put("flag", 0);
			hashMap.put("lineKey", "ycnId");
			hashMap.put("lineValue", ycnId);
			Issueclassnotice issueclassnotice = ixuestarCloudELMapper.getYxIssueclassnotices(hashMap).get(0);
			if (issueclassnotice!=null) {
				//判断类型
				Integer ycnAnwType = issueclassnotice.getYcnAnwType();
				String ixstId = issueclassnotice.getIxstId();
				hashMap.put("lineKey", "ixstId");
				hashMap.put("lineValue", ixstId);
				List<SchoolTeacher> schoolTeachers = ixuestarCloudELMapper.getSchoolTeachers(hashMap);
				if (schoolTeachers.size()!=0) {
					String ixstName = schoolTeachers.get(0).getIxstName();
					JSONObject issuenoticeObject = (JSONObject)JSON.toJSON(issueclassnotice);
					issuenoticeObject.put("ixstName", ixstName);
					//获取通知的文件信息
					hashMap.put("flag", 0);
					hashMap.put("lineKey", "ycnId");
					hashMap.put("lineValue", ycnId);
					List<IssueclassFile> issueclassFilesList = ixuestarCloudELMapper.getIssueclassFilesList(hashMap);
					issuenoticeObject.put("ycnFileList", issueclassFilesList);
					//获取是否查看
					JSONObject replyObject = new JSONObject();
					if (ycnAnwType==0) {
						hashMap.put("flag", 0);
						hashMap.put("fllag", 0);
						hashMap.put("flllag", 1);
						hashMap.put("ycnId", ycnId);
						hashMap.put("ixssId", ixssId);
						List<YxChecknotice> yxChecknoticesInfo = ixuestarCloudELMapper.getYxChecknoticesInfo(hashMap);
						if (yxChecknoticesInfo.size()==0) {
							issuenoticeObject.put("icheck", 0);
						}else {
							issuenoticeObject.put("icheck", 1);
						}
					}else {
						hashMap.put("flag", 0);
						hashMap.put("fllag", 0);
						hashMap.put("flllag", 1);
						hashMap.put("ycnId", ycnId);
						hashMap.put("ixssId", ixssId);
						List<Replytoclassnotice> replytoclassnotices = ixuestarCloudELMapper.getReplytoclassnotices(hashMap);
						if (replytoclassnotices.size()==0) {
							issuenoticeObject.put("icheck", 2);
						}else {
							Replytoclassnotice replytoclassnotice = replytoclassnotices.get(0);
							String yrcnId = replytoclassnotice.getYrcnId();
							hashMap.put("lineKey", "yrcnId");
							hashMap.put("lineValue", yrcnId);
							List<Replytoclassfile> replytoclassfiles = ixuestarCloudELMapper.getReplytoclassfiles(hashMap);
							JSONObject replynObject = (JSONObject)JSON.toJSON(replytoclassnotice);
							replynObject.put("replytoclassfiles", replytoclassfiles);
							replyObject.putAll(replynObject);
							issuenoticeObject.put("icheck", 3);
						}
					}
					issuenoticeObject.put("replynotice", replyObject);
					jsonArray.add(issuenoticeObject);
				}
			}
		}
		//计算页码
		Integer remainPage = total / pageLimit;
		Integer totalPage = total % pageLimit == 0?remainPage:remainPage+1;
		//结果返回
		resultObject.put("currentPage", pageIndex);
		resultObject.put("totalResult", total);
		resultObject.put("totalPage", totalPage);
		resultObject.put("limitResult", pageLimit);
		resultObject.put("dataObject", jsonArray);
		//返回
		return resultObject;
	}
	
	@Override
	public JSONObject writeReplytonotice(Integer ycnFlag,String yrcnContent, String ycnId, String ixssId, JSONArray list) {
		// TODO Auto-generated method stub
		int code = 0;
		Map<String, Object> hashMap = new HashMap<>();
		JSONObject resultObject = new JSONObject();
		//首先判断一下学生是否有回复权限
		hashMap.put("flag", 0);
		hashMap.put("fllag", 0);
		hashMap.put("ycnFlag", ycnFlag);
		hashMap.put("lineKey", "ycn.ycnId");
		hashMap.put("lineValue", ycnId);
		List<YxIcnClass> yxIcnClasses = ixuestarCloudELMapper.getYxIcnClassesList(hashMap);
		if (yxIcnClasses.size()==0) {
			code = 1;
		}else {
			hashMap.put("lineKey", "ixssId");
			hashMap.put("lineValue", ixssId);
			List<SchoolStudent> schoolStudents = ixuestarCloudELMapper.getSchoolStudents(hashMap);
			if (schoolStudents.size()==0) {
				code = 2;
			}else {
				boolean authority = false;
				String ixscId = schoolStudents.get(0).getIxscId();
				for (int i = 0; i < yxIcnClasses.size(); i++) {
					String ixscId2 = yxIcnClasses.get(i).getIxscId();
					if (ixscId.equals(ixscId2)) {
						authority = true;
						break;
					}
				}
				if (authority) {
					hashMap.put("flllag", 1);
					hashMap.put("ycnId", ycnId);
					hashMap.put("ixssId", ixssId);
					List<Replytoclassnotice> replytoclassnotices = ixuestarCloudELMapper.getReplytoclassnotices(hashMap);
					if (replytoclassnotices.size()==0) {
						//写入回复内容
						String yrcnId = "yrcn" + new Date().getTime() + (int)(Math.random()*10);
						String yrcnCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
						//写入
						Replytoclassnotice replytoclassnotice = new Replytoclassnotice();
						replytoclassnotice.setYrcnId(yrcnId);
						replytoclassnotice.setYrcnContent(yrcnContent);
						replytoclassnotice.setYrcnCreatetime(yrcnCreatetime);
						replytoclassnotice.setIxssId(ixssId);
						replytoclassnotice.setIxscId(ixscId);
						replytoclassnotice.setYcnId(ycnId);
						ixuestarCloudELMapper.writeReplytoclassnotice(replytoclassnotice);
						//写入文件的id
						for (int i = 0; i < list.size(); i++) {
							String yrcfId = list.getString(i);
							//写入修改
							hashMap.put("yrcnId", yrcnId);
							hashMap.put("yrcfId", yrcfId);
							ixuestarCloudELMapper.updateReplytoclassfiles(hashMap);
						}
						//获取文件列表
						hashMap.put("lineKey", "yrcnId");
						hashMap.put("lineValue", yrcnId);
						List<Replytoclassfile> replytoclassfiles = ixuestarCloudELMapper.getReplytoclassfiles(hashMap);
						//写入反馈给老师的结果
						JSONObject dataObject = (JSONObject)JSON.toJSON(replytoclassnotice);
						resultObject.putAll(dataObject);
						resultObject.put("replyFiles", replytoclassfiles);
						//获取老师的id
						hashMap.put("flag", 0);
						hashMap.put("lineKey", "ycnId");
						hashMap.put("lineValue", ycnId);
						List<Issueclassnotice> yxIssueclassnotices = ixuestarCloudELMapper.getYxIssueclassnotices(hashMap);
						if (yxIssueclassnotices.size()!=0) {
							String ixstId = yxIssueclassnotices.get(0).getIxstId();
							//获取微信信息id
							hashMap.put("lineKey", "ixssId");
							hashMap.put("lineValue", ixstId);
							YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
							if (yxWxuser!=null) {
								String ywId = yxWxuser.getYwId();
								try {
									WebSocketController.sendInfo(dataObject.toJSONString(), ywId);
								} catch (IOException e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								}
							}
						}
					}else {
						code = 4;
					}
				}else {
					code = 3;
				}
			}
		}
		resultObject.put("code", code);
		return resultObject;
	}
	
	@Override
	public JSONObject writeChecktheNoticeInfo(Integer ycnFlag,String ycnId, String ixssId) {
		// TODO Auto-generated method stub
		JSONObject resultObject = new JSONObject();
		int code = 0;
		//首先判断传入的id有误权限查看
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ixssId");
		hashMap.put("lineValue", ixssId);
		List<SchoolStudent> schoolStudents = ixuestarCloudELMapper.getSchoolStudents(hashMap);
		if (schoolStudents.size()==0) {
			code = 1;
		}else {
			SchoolStudent schoolStudent = schoolStudents.get(0);
			if (schoolStudent!=null) {
				String ixscId = schoolStudent.getIxscId();
				logger.info("通过学生信息"+ixssId+"查询到的班级信息id："+ixscId);
				//获取通知涉及的班级
				boolean itrue = false;
				hashMap.put("lineKey", "ycn.ycnId");
				hashMap.put("lineValue", ycnId);
				hashMap.put("ycnFlag", ycnFlag);
				List<YxIcnClass> yxIcnClassesList = ixuestarCloudELMapper.getYxIcnClassesList(hashMap);
				for (int i = 0; i < yxIcnClassesList.size(); i++) {
					String ixscId2 = yxIcnClassesList.get(i).getIxscId();
					logger.info("通过消息通知信息id："+ycnId+"查询到的班级信息id："+ixscId2);
					if (ixscId2.equals(ixscId)) {
						itrue = true;
						break;
					}
				}
				if (itrue) {
					hashMap.put("flllag", 1);
					hashMap.put("ycnId", ycnId);
					hashMap.put("ixssId", ixssId);
					List<YxChecknotice> yxChecknoticesInfo = ixuestarCloudELMapper.getYxChecknoticesInfo(hashMap);
					if (yxChecknoticesInfo.size()==0) {
						YxChecknotice yxChecknotice = new YxChecknotice();
						String yctnId = "yctn" + new Date().getTime() + (int)(Math.random()*10);
						String yctnCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
						yxChecknotice.setYctnId(yctnId);
						yxChecknotice.setYcnId(ycnId);
						yxChecknotice.setIxssId(ixssId);
						yxChecknotice.setIxscId(ixscId);
						yxChecknotice.setYctnCreatetime(yctnCreatetime);
						ixuestarCloudELMapper.writeChecktheNotice(yxChecknotice);
						resultObject.putAll((JSONObject)JSON.toJSON(yxChecknotice));
					}else {
						code = 3;
					}
				}else {
					code = 2;
				}
			}
		}
		resultObject.put("code", code);
		return resultObject;
	}
	
	@Override
	public JSONObject getCheckHomeworkList(Integer ycnRequest, Integer ycnFlag, String ixssId, String ixscId, Integer pageIndex,
			Integer pageLimit) {
		// TODO Auto-generated method stub
		//创建参数容器并定义参数
		int code = 0;
		Integer totalNum = 0;
		JSONArray jsonArray = new JSONArray();
		JSONObject resultObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		List<Issueclassnotice> issueclassnotices = null;
		//获取未查看消息
		if (ycnRequest==0) {
			//获取消息总数
			hashMap.put("flag", 1);
			hashMap.put("ixscId", ixscId);
			hashMap.put("ycnFlag", ycnFlag);
			List<Issueclassnotice> allIssueclassnotices = ixuestarCloudELMapper.getAllIssueclassnotices(hashMap);
			//获取消息总数
			int totalNotice = allIssueclassnotices.size();
			//获取已读
			hashMap.put("flag", 1);
			hashMap.put("fllag", 0);
			hashMap.put("ixssId", ixssId);
			hashMap.put("ycnFlag", ycnFlag);
			List<Issueclassnotice> checkIssueclassnotices = ixuestarCloudELMapper.getCheckIssueclassnotices(hashMap);
			//获取已读消息总数
			int checkNotice = checkIssueclassnotices.size();
			//未读消息
			totalNum = totalNotice - checkNotice;
			List<Issueclassnotice> linkedList = new LinkedList<>();
			allIssueclassnotices.stream().forEach(ss -> {
				if (!checkIssueclassnotices.contains(ss)) {
					linkedList.add(ss);
				}
			});
			//首先定义页码与大小
			List<Issueclassnotice> nocheckIssueclassnotices = new LinkedList<>();
			Integer firstResult = (pageIndex - 1) * pageLimit;
			Integer limitResult = pageLimit;
			for (int i = firstResult; i < (firstResult + limitResult); i++) {
				try {
					Issueclassnotice issueclassnotice = linkedList.get(i);
					nocheckIssueclassnotices.add(issueclassnotice);
				} catch (Exception e) {
					// TODO: handle exception
					System.out.println("超出索引");
					break;
				}
			}
			issueclassnotices = nocheckIssueclassnotices;
		} else if(ycnRequest==1) {
			//获取消息总数
			hashMap.put("flag", 1);
			hashMap.put("fllag", 0);
			hashMap.put("ixssId", ixssId);
			hashMap.put("ycnFlag", ycnFlag);
			totalNum = ixuestarCloudELMapper.getCheckIssueclassnotices(hashMap).size();
			//首先定义页码与大小
			Integer firstResult = (pageIndex - 1) * pageLimit;
			Integer limitResult = pageLimit;
			hashMap.put("flag", 1);
			hashMap.put("fllag", 1);
			hashMap.put("firstResult", firstResult);
			hashMap.put("limitResult", limitResult);
			issueclassnotices = ixuestarCloudELMapper.getCheckIssueclassnotices(hashMap);
		}
		//判断
		if (issueclassnotices!=null) {
			for (int i = 0; i < issueclassnotices.size(); i++) {
				Issueclassnotice issueclassnotice = issueclassnotices.get(i);
				String ycnId = issueclassnotice.getYcnId();
				//获取
				if (issueclassnotice!=null) {
					//判断类型
					Integer ycnAnwType = issueclassnotice.getYcnAnwType();
					String ixstId = issueclassnotice.getIxstId();
					hashMap.put("lineKey", "ixstId");
					hashMap.put("lineValue", ixstId);
					List<SchoolTeacher> schoolTeachers = ixuestarCloudELMapper.getSchoolTeachers(hashMap);
					if (schoolTeachers.size()!=0) {
						String ixstName = schoolTeachers.get(0).getIxstName();
						JSONObject issuenoticeObject = (JSONObject)JSON.toJSON(issueclassnotice);
						issuenoticeObject.put("ixstName", ixstName);
						//获取通知的文件信息
						hashMap.put("flag", 0);
						hashMap.put("lineKey", "ycnId");
						hashMap.put("lineValue", ycnId);
						List<IssueclassFile> issueclassFilesList = ixuestarCloudELMapper.getIssueclassFilesList(hashMap);
						issuenoticeObject.put("ycnFileList", issueclassFilesList);
						//获取是否查看
						JSONObject replyObject = new JSONObject();
						if (ycnAnwType==0) {
							hashMap.put("flag", 0);
							hashMap.put("fllag", 0);
							hashMap.put("flllag", 1);
							hashMap.put("ycnId", ycnId);
							hashMap.put("ixssId", ixssId);
							List<YxChecknotice> yxChecknoticesInfo = ixuestarCloudELMapper.getYxChecknoticesInfo(hashMap);
							if (yxChecknoticesInfo.size()==0) {
								issuenoticeObject.put("icheck", 0);
							}else {
								issuenoticeObject.put("icheck", 1);
							}
						}else {
							hashMap.put("flag", 0);
							hashMap.put("fllag", 0);
							hashMap.put("flllag", 1);
							hashMap.put("ycnId", ycnId);
							hashMap.put("ixssId", ixssId);
							List<Replytoclassnotice> replytoclassnotices = ixuestarCloudELMapper.getReplytoclassnotices(hashMap);
							if (replytoclassnotices.size()==0) {
								issuenoticeObject.put("icheck", 2);
							}else {
								Replytoclassnotice replytoclassnotice = replytoclassnotices.get(0);
								String yrcnId = replytoclassnotice.getYrcnId();
								hashMap.put("lineKey", "yrcnId");
								hashMap.put("lineValue", yrcnId);
								List<Replytoclassfile> replytoclassfiles = ixuestarCloudELMapper.getReplytoclassfiles(hashMap);
								JSONObject replynObject = (JSONObject)JSON.toJSON(replytoclassnotice);
								replynObject.put("replytoclassfiles", replytoclassfiles);
								replyObject.putAll(replynObject);
								issuenoticeObject.put("icheck", 3);
							}
						}
						issuenoticeObject.put("replynotice", replyObject);
						jsonArray.add(issuenoticeObject);
					}
				}
			}
		}else {
			code = 1;
		}
		//计算页码
		Integer remainPage = totalNum / pageLimit;
		Integer totalPage = totalNum % pageLimit == 0?remainPage:remainPage+1;
		//结果返回
		resultObject.put("code", code);
		resultObject.put("currentPage", pageIndex);
		resultObject.put("totalResult", totalNum);
		resultObject.put("totalPage", totalPage);
		resultObject.put("limitResult", pageLimit);
		resultObject.put("dataObject", jsonArray);
		return resultObject;
	}
	
	@Override
	public JSONObject getCheckNoticeInfo(String ycnId, String ixscId, String openId) {
		// TODO Auto-generated method stub
		int code = 0;
		JSONObject jsonObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		//首先判断用户是否存在此用户
		hashMap.put("lineKey", "ywOpenId");
		hashMap.put("lineValue", openId);
		YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
		if (yxWxuser==null) {
			code = 1;
		}else {
			String ixssId = yxWxuser.getIxssId();
			if (ixssId==null) {
				code = 2;
			}else {
				//获取学生班级
				hashMap.put("lineKey", "ixssId");
				hashMap.put("lineValue", ixssId);
				List<SchoolStudent> schoolStudents = ixuestarCloudELMapper.getSchoolStudents(hashMap);
				//如果拥有此用户 看是否为本班级的人
				SchoolStudent schoolStudent = schoolStudents.get(0);
				String ixscId2 = schoolStudent.getIxscId();
				if (!ixscId2.equals(ixscId)) {
					code = 3;
				}else {
					//为本班级的人的话 查看出消息详情
					hashMap.put("flag", 0);
					hashMap.put("lineKey", "ycnId");
					hashMap.put("lineValue", ycnId);
					Issueclassnotice issueclassnotice = ixuestarCloudELMapper.getYxIssueclassnotices(hashMap).get(0);
					if (issueclassnotice!=null) {
						//判断类型
						Integer ycnAnwType = issueclassnotice.getYcnAnwType();
						String ixstId = issueclassnotice.getIxstId();
						hashMap.put("lineKey", "ixstId");
						hashMap.put("lineValue", ixstId);
						List<SchoolTeacher> schoolTeachers = ixuestarCloudELMapper.getSchoolTeachers(hashMap);
						if (schoolTeachers.size()!=0) {
							String ixstName = schoolTeachers.get(0).getIxstName();
							JSONObject issuenoticeObject = (JSONObject)JSON.toJSON(issueclassnotice);
							issuenoticeObject.put("ixstName", ixstName);
							//获取通知的文件信息
							hashMap.put("flag", 0);
							hashMap.put("lineKey", "ycnId");
							hashMap.put("lineValue", ycnId);
							List<IssueclassFile> issueclassFilesList = ixuestarCloudELMapper.getIssueclassFilesList(hashMap);
							issuenoticeObject.put("ycnFileList", issueclassFilesList);
							//获取是否查看
							JSONObject replyObject = new JSONObject();
							if (ycnAnwType==0) {
								hashMap.put("flag", 0);
								hashMap.put("fllag", 0);
								hashMap.put("flllag", 1);
								hashMap.put("ycnId", ycnId);
								hashMap.put("ixssId", ixssId);
								List<YxChecknotice> yxChecknoticesInfo = ixuestarCloudELMapper.getYxChecknoticesInfo(hashMap);
								if (yxChecknoticesInfo.size()==0) {
									issuenoticeObject.put("icheck", 0);
								}else {
									issuenoticeObject.put("icheck", 1);
								}
							}else {
								hashMap.put("flag", 0);
								hashMap.put("fllag", 0);
								hashMap.put("flllag", 1);
								hashMap.put("ycnId", ycnId);
								hashMap.put("ixssId", ixssId);
								List<Replytoclassnotice> replytoclassnotices = ixuestarCloudELMapper.getReplytoclassnotices(hashMap);
								if (replytoclassnotices.size()==0) {
									issuenoticeObject.put("icheck", 2);
								}else {
									Replytoclassnotice replytoclassnotice = replytoclassnotices.get(0);
									String yrcnId = replytoclassnotice.getYrcnId();
									hashMap.put("lineKey", "yrcnId");
									hashMap.put("lineValue", yrcnId);
									List<Replytoclassfile> replytoclassfiles = ixuestarCloudELMapper.getReplytoclassfiles(hashMap);
									JSONObject replynObject = (JSONObject)JSON.toJSON(replytoclassnotice);
									replynObject.put("replytoclassfiles", replytoclassfiles);
									replyObject.putAll(replynObject);
									issuenoticeObject.put("icheck", 3);
								}
							}
							issuenoticeObject.put("replynotice", replyObject);
							jsonObject.putAll(issuenoticeObject);
						}
						
					}
				}
			}
		}
		jsonObject.put("code", code);
		return jsonObject;
	}
	
	@Override
	public JSONObject getStutestscoresList(String ixscId, Integer pageIndex, Integer pageLimit) {
		// TODO Auto-generated method stub
		JSONObject resultObject = new JSONObject();
		//获取结果总数
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("flaag", 1);
		hashMap.put("yenStatus", 1);
		hashMap.put("ixscId", ixscId);
		int totalResult = ixuestarCloudELMapper.getYxExaminations(hashMap).size();
		//首先定义页码参数
		Integer firstResult = (pageIndex - 1) * pageLimit;
		Integer limitResult = pageLimit;
		hashMap.put("fllag", 1);
		hashMap.put("firstResult", firstResult);
		hashMap.put("limitResult", limitResult);
		JSONArray jsonArray = new JSONArray();
		List<YxExamination> examinationsList = ixuestarCloudELMapper.getYxExaminations(hashMap);
		for (int i = 0; i < examinationsList.size(); i++) {
			YxExamination yxExamination = examinationsList.get(i);
			String ixstId = yxExamination.getIxstId();
			//获取教师名称
			hashMap.put("lineKey", "ixstId");
			hashMap.put("lineValue", ixstId);
			List<SchoolTeacher> schoolTeachers = ixuestarCloudELMapper.getSchoolTeachers(hashMap);
			String ixstName = "";
			if (schoolTeachers.size()!=0) {
				ixstName = schoolTeachers.get(0).getIxstName();
			}
			JSONObject examObject = JSONObject.parseObject(JSON.toJSONString(yxExamination));
			examObject.put("ixstName", ixstName);
			jsonArray.add(examObject);
		}
		//计算页码
		Integer remainPage = totalResult / pageLimit;
		Integer totalPage = totalResult % pageLimit == 0?remainPage:remainPage+1;
		//添加到结果对象
		resultObject.put("dataList", jsonArray);
		resultObject.put("totalPage", totalPage);
		resultObject.put("currentPage", pageIndex);
		resultObject.put("totalResult", totalResult);
		resultObject.put("limitResult", limitResult);
		return resultObject;
	}
	
	@Override
	public JSONObject getStuExaminationsInfo(String ixscId, String ixssId, String yenId) {
		// TODO Auto-generated method stub
		int code = 0;
		JSONObject resultObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		//首先获取考试详情信息
		YxExamination yxExaminationInfo = ixuestarCloudELMapper.getYxExaminationInfo(yenId);
		if (yxExaminationInfo!=null) {
			resultObject.put("examInfo", yxExaminationInfo);
			//获取学生的考试成绩
			hashMap.put("flag", 1);
			hashMap.put("ixssId", ixssId);
			hashMap.put("lineKey", "yenId");
			hashMap.put("lineValue", yenId);
			List<Yxtestscores> yxtestscoreList = ixuestarCloudELMapper.getYxtestscoreList(hashMap);
			if (yxtestscoreList.size()!=0) {
				Yxtestscores yxtestscores = yxtestscoreList.get(0);
				resultObject.put("scoreInfo", yxtestscores);
				//查询近十天的打卡情况
				String stopDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
				Calendar instance = Calendar.getInstance();
				instance.add(Calendar.DATE, -9);
				String startDate = new SimpleDateFormat("yyyy-MM-dd").format(instance.getTime()) + " 00:00:00";
				
				hashMap.put("ixssId", ixssId);
				hashMap.put("startDate", startDate);
				hashMap.put("stopDate", stopDate);
				List<YxWatchAds> watchAdsList = ixuestarCloudELMapper.getWatchAdsList(hashMap);
				if (watchAdsList.size()>=8) {
					
					//获取平均数和其他信息
					Temp scoresavgmaxmin = ixuestarCloudELMapper.getScoresavgmaxmin(yenId);
					String average = String.format("%.2f", Double.parseDouble(scoresavgmaxmin.getA()));
					logger.info("------scoresavgmaxmin-"+scoresavgmaxmin.getA()+"---"+scoresavgmaxmin.getA().length()+"---");
					
					scoresavgmaxmin.setA(average);
					resultObject.put("scoresavgmaxmin", scoresavgmaxmin);
					//获取历次的考试成绩
					hashMap.put("flag", 1);
					hashMap.put("fllag", 3);
					hashMap.put("lineValue", 1);
					hashMap.put("ixssId", ixssId);
					hashMap.put("lineKey", "ytsStatus");
					JSONArray jsonArray = new JSONArray();
					List<Yxtestscores> yxtestscoreLists = ixuestarCloudELMapper.getYxtestscoreList(hashMap);
					for (int i = 0; i < yxtestscoreLists.size(); i++) {
						Yxtestscores yxtestscores2 = yxtestscoreLists.get(i);
						//获取考试信息
						String yenId2 = yxtestscores2.getYenId();
						YxExamination yxExaminationInfos = ixuestarCloudELMapper.getYxExaminationInfo(yenId2);
						JSONObject parseObject = JSONObject.parseObject(JSON.toJSONString(yxExaminationInfos));
						parseObject.put("scoreObject", yxtestscores2);
						jsonArray.add(parseObject);
					}
					resultObject.put("scoreList", jsonArray);
					//获取分数分段
					hashMap.put("lineKey", "ixscId");
					hashMap.put("lineValue", ixscId);
					int studentNum = ixuestarCloudELMapper.getSchoolStudents(hashMap).size();
					JSONArray interArray = new JSONArray();
					Integer firstScore = 0;
					Integer limitScore = 60;
					hashMap.put("yenId", yenId);
					hashMap.put("firstScore", firstScore);
					hashMap.put("limitScore", limitScore);
					int scoreNum0 = ixuestarCloudELMapper.getYxtestscores(hashMap).size();
					JSONObject scoreObject0 = new JSONObject();
					scoreObject0.put("scoreInterval", "[0~60)");
					scoreObject0.put("scoreNum", scoreNum0);
					scoreObject0.put("scorePro", (String.format("%.2f", scoreNum0*100.00/studentNum))+"%");
					interArray.add(scoreObject0);
					// 60~75
					firstScore = 60;
					limitScore = 75;
					hashMap.put("firstScore", firstScore);
					hashMap.put("limitScore", limitScore);
					JSONObject scoreObject1 = new JSONObject();
					int scoreNum1 = ixuestarCloudELMapper.getYxtestscores(hashMap).size();
					scoreObject1.put("scoreInterval", "[60~75)");
					scoreObject1.put("scoreNum", scoreNum1);
					scoreObject1.put("scorePro", (String.format("%.2f", scoreNum1*100.00/studentNum))+"%");
					interArray.add(scoreObject1);
					// 75~90
					firstScore = 75;
					limitScore = 90;
					hashMap.put("firstScore", firstScore);
					hashMap.put("limitScore", limitScore);
					JSONObject scoreObject2 = new JSONObject();
					int scoreNum2 = ixuestarCloudELMapper.getYxtestscores(hashMap).size();
					scoreObject2.put("scoreInterval", "[75~90)");
					scoreObject2.put("scoreNum", scoreNum2);
					scoreObject2.put("scorePro", (String.format("%.2f", scoreNum2*100.00/studentNum))+"%");
					interArray.add(scoreObject2);
					//90~100
					firstScore = 90;
					limitScore = 101;
					hashMap.put("firstScore", firstScore);
					hashMap.put("limitScore", limitScore);
					JSONObject scoreObject3 = new JSONObject();
					int scoreNum3 = ixuestarCloudELMapper.getYxtestscores(hashMap).size();
					scoreObject3.put("scoreInterval", "[90~100]");
					scoreObject3.put("scoreNum", scoreNum3);
					scoreObject3.put("scorePro", (String.format("%.2f", scoreNum3*100.00/studentNum))+"%");
					interArray.add(scoreObject3);
					//添加到结果对象
					resultObject.put("scoreInterval", interArray);
				}else {
					code = 1;
				}
			}else {
				code = 2;
			}
		}else {
			code = 3;
		}
		resultObject.put("code", code);
		return resultObject;
	}
	
	@Override
	public Integer getNumberofcheckins(String ywOpenId) {
		// TODO Auto-generated method stub
		//查询最近七天的签到情况
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("ywId", ywOpenId);
		hashMap.put("ywaType0", 1);
		hashMap.put("ywaType1", 3);
		//获取日期
		Integer num = 0;
		String mondayOFWeek = DateUtil.getMondayOFWeek();
		for (int i = 0; i < 7; i++) {
			Calendar instance = Calendar.getInstance();
			instance.add(Calendar.DATE, -i);
			String tDate = new SimpleDateFormat("yyyy-MM-dd").format(instance.getTime());
			hashMap.put("ywaPlayDate", tDate);
			List<YxWatchAds> watchAdsInfos = ixuestarCloudELMapper.getWatchAdsInfos(hashMap);
			if (watchAdsInfos.size()!=0) {
				num += 1;
			}else {
				break;
			}
			if (mondayOFWeek.equals(tDate)) break;
		}
		return num;
	}
	
	@Override
	public JSONObject getLotteryInfo(String ixsgId, String ixsId) {
		// TODO Auto-generated method stub
		int code = 0;
		JSONObject resultObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		//获取学校的抽奖信息
		hashMap.put("lineKey", "ixsgId");
		hashMap.put("lineValue", ixsgId);
		YxLotterySchool lotterySchool = ixuestarCloudELMapper.getLotterySchool(hashMap);
		if (lotterySchool!=null) {
			String ylId = lotterySchool.getYlId();
			//获取奖品的条目信息
			YxLotteryInfo yxLotteryInfo = ixuestarCloudELMapper.getYxLotteryInfo(ylId);
			if (yxLotteryInfo!=null) {
				//获取条目的奖品列表
				hashMap.put("lineKey", "ylId");
				hashMap.put("lineValue", ylId);
				JSONArray prizeArray = new JSONArray();
				List<YxLotteryPrize> yxLotteryPrizes = ixuestarCloudELMapper.getYxLotteryPrizes(hashMap);
				for (int i = 0; i < yxLotteryPrizes.size(); i++) {
					YxLotteryPrize yxLotteryPrize = yxLotteryPrizes.get(i);
					//获取奖品的详细信息
					String ypId = yxLotteryPrize.getYpId();
					YxPrizeInfo prizeInfo = ixuestarCloudELMapper.getPrizeInfo(ypId);
					prizeArray.add(prizeInfo);
				}
				JSONObject lotteryObject = (JSONObject)JSON.toJSON(yxLotteryInfo);
				lotteryObject.put("prizeList", prizeArray);
				resultObject.putAll(lotteryObject);
			}else {
				code = 2;
			}
		}else {
			code = 1;
		}
		resultObject.put("code", code);
		return resultObject;
	}
	
	@Override
	public JSONObject getluckydraw(Integer yrlType, String ywId, String ylId) {
		// TODO Auto-generated method stub
		int code = 0;
		JSONObject resultObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		if (yrlType==0) {
			//定义
			String ypId = "yp0000000000";
			YxLotteryRecord yxLotteryRecord = new YxLotteryRecord();
			String ylrId = "ylr" + (new Date().getTime()+(int)(Math.random()*10)) + (int)(Math.random()*10);
			String ylrCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			yxLotteryRecord.setYlrId(ylrId);
			yxLotteryRecord.setYwId(ywId);
			yxLotteryRecord.setYpId(ypId);
			yxLotteryRecord.setYlrCreatetime(ylrCreatetime);
			ixuestarCloudELMapper.writeYxLotteryRecord(yxLotteryRecord);
			//获取抽奖信息
			YxPrizeInfo prizeInfo = ixuestarCloudELMapper.getPrizeInfo(ypId);
			if (prizeInfo!=null) {
				resultObject.putAll((JSONObject)JSON.toJSON(prizeInfo));
			}
		}else if (yrlType==1) {
			//获取签到情况
			hashMap.put("lineKey", "ywId");
			hashMap.put("lineValue", ywId);
			YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
			if (yxWxuser!=null) {
				String ywOpenId = yxWxuser.getYwOpenId();
				Integer numberofcheckins = getNumberofcheckins(ywOpenId);
				if (numberofcheckins==7) {
					//获取近两个月是否获奖
					Calendar instance = Calendar.getInstance();
					instance.add(Calendar.MONTH, -2);
					String lastwomonth = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(instance.getTime());
					hashMap.put("fag", 0);
					hashMap.put("faag", 1);
					hashMap.put("flag", 0);
					hashMap.put("yulCreatetime", lastwomonth);
					int lotternum = ixuestarCloudELMapper.getYxuserLotteries(hashMap).size();
					if (lotternum==0) {
						//获取奖品列表
						hashMap.put("lineKey", "ylId");
						hashMap.put("lineValue", ylId);
						List<ProbabilityEntity<Object>> prizeList = new LinkedList<>();
						List<YxLotteryPrize> yxLotteryPrizes = ixuestarCloudELMapper.getYxLotteryPrizes(hashMap);
						for (int i = 0; i < yxLotteryPrizes.size(); i++) {
							ProbabilityEntity<Object> probabilityEntity = new ProbabilityEntity<>();
							YxLotteryPrize yxLotteryPrize = yxLotteryPrizes.get(i);
							//获取奖品的详细信息
							String ypId = yxLotteryPrize.getYpId();
							probabilityEntity.setId(ypId);
							String ylpId = yxLotteryPrize.getYlpId();
							probabilityEntity.setEntity(ylpId);
							Double ylproportion = yxLotteryPrize.getYlproportion();
							probabilityEntity.setProbabilityValue(ylproportion);
							prizeList.add(probabilityEntity);
						}
						//创建默认奖品
						ProbabilityEntity<Object> probabilityEntity = new ProbabilityEntity<>();
						probabilityEntity.setId("yp0000000000");
						probabilityEntity.setEntity("谢谢参与:)");
						probabilityEntity.setProbabilityValue(0.0);
						//调用抽奖方法
						ProbabilityEntity<Object> probabilityLottery = MyAlgorithmUtil.probabilityLottery(prizeList, probabilityEntity);
						//获取详细奖品信息
						String id = probabilityLottery.getId();
						//获取奖品的个数
						hashMap.put("ylId", ylId);
						hashMap.put("ypId", id);
						YxLotteryPrize yxLotteryPrize = ixuestarCloudELMapper.getYxLotteryPrize(hashMap);
						if (yxLotteryPrize!=null) {
							int ylperopleNum = yxLotteryPrize.getYlperopleNum();
							if (ylperopleNum!=-1) {
								//查询已中奖的人数
								String ylStartDate = yxLotteryPrize.getYlStartDate();
								hashMap.put("fag", 0);
								hashMap.put("faag", 1);
								hashMap.put("flag", 0);
								hashMap.put("lineValue", id);
								hashMap.put("lineKey", "ypId");
								hashMap.put("yulCreatetime", ylStartDate);
								int num = ixuestarCloudELMapper.getYxuserLotteries(hashMap).size();;
								if (ylperopleNum>num) {
									YxPrizeInfo prizeInfo = ixuestarCloudELMapper.getPrizeInfo(id);
									if (prizeInfo!=null) {
										resultObject.putAll((JSONObject)JSON.toJSON(prizeInfo));
									}
								}else {
									id = "yp0000000000";
									YxPrizeInfo prizeInfo = ixuestarCloudELMapper.getPrizeInfo("yp0000000000");
									if (prizeInfo!=null) {
										resultObject.putAll((JSONObject)JSON.toJSON(prizeInfo));
									}
								}
							}
						}
						//写入抽奖记录
						YxLotteryRecord yxLotteryRecord = new YxLotteryRecord();
						String ylrId = "ylr" + (new Date().getTime()+(int)(Math.random()*10)) + (int)(Math.random()*10);
						String ylrCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
						yxLotteryRecord.setYlrId(ylrId);
						yxLotteryRecord.setYwId(ywId);
						yxLotteryRecord.setYpId(id);
						yxLotteryRecord.setYlrCreatetime(ylrCreatetime);
						ixuestarCloudELMapper.writeYxLotteryRecord(yxLotteryRecord);
						//判断
						if (!id.equals("yp0000000000")) {
							//写入抽奖信息
							YxuserLottery yxuserLottery = new YxuserLottery();
							//创建id和时间
							String yulId = "yul" + (new Date().getTime()+(int)(Math.random()*10)) + (int)(Math.random()*10);
							String yulCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
							yxuserLottery.setYulId(yulId);
							yxuserLottery.setYwId(ywId);
							yxuserLottery.setYpId(id);
							yxuserLottery.setYulStatus(0);
							yxuserLottery.setYulCreatetime(yulCreatetime);
							ixuestarCloudELMapper.writeWxuserPrizeInfo(yxuserLottery);
						}
					}else {
						//定义
						String ypId = "yp0000000000";
						YxLotteryRecord yxLotteryRecord = new YxLotteryRecord();
						String ylrId = "ylr" + (new Date().getTime()+(int)(Math.random()*10)) + (int)(Math.random()*10);
						String ylrCreatetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
						yxLotteryRecord.setYlrId(ylrId);
						yxLotteryRecord.setYwId(ywId);
						yxLotteryRecord.setYpId(ypId);
						yxLotteryRecord.setYlrCreatetime(ylrCreatetime);
						ixuestarCloudELMapper.writeYxLotteryRecord(yxLotteryRecord);
						//获取抽奖信息
						YxPrizeInfo prizeInfo = ixuestarCloudELMapper.getPrizeInfo(ypId);
						if (prizeInfo!=null) {
							resultObject.putAll((JSONObject)JSON.toJSON(prizeInfo));
						}
					}
				}else {
					code = 2;
				}
			}else {
				code = 1;
			}
		}
		resultObject.put("code", code);
		//返回
		return resultObject;
	}
	
	@Override
	public JSONObject getPrizeList(String ywId, Integer yulStatus, Integer pageIndex, Integer pageLimit) {
		// TODO Auto-generated method stub
		JSONObject resultObject = new JSONObject();
		//获取所有奖品信息
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("fag", 1);
		hashMap.put("flag", 0);
		hashMap.put("lineKey", "ywId");
		hashMap.put("lineValue", ywId);
		hashMap.put("yulStatus", yulStatus);
		int totalResult = ixuestarCloudELMapper.getYxuserLotteries(hashMap).size();
		//定义页码
		Integer firstResult = (pageIndex - 1) * pageLimit;
		Integer limitResult = pageLimit;	
		hashMap.put("flag", 1);
		hashMap.put("firstResult", firstResult);
		hashMap.put("limitResult", limitResult);
		JSONArray userArray = new JSONArray();
		List<YxuserLottery> userLotteries = ixuestarCloudELMapper.getYxuserLotteries(hashMap);
		for (int i = 0; i < userLotteries.size(); i++) {
			YxuserLottery yxuserLottery = userLotteries.get(i);
			//获取id
			String ypId = yxuserLottery.getYpId();
			YxPrizeInfo prizeInfo = ixuestarCloudELMapper.getPrizeInfo(ypId);
			
			String yulCreatetime = yxuserLottery.getYulCreatetime();
			prizeInfo.setYpCreatetime(yulCreatetime);
			userArray.add(prizeInfo);
		}
		//计算页码
		Integer remainPage = totalResult / pageLimit;
		Integer totalPage = totalResult % pageLimit == 0?remainPage:remainPage+1;
		//添加到结果对象
		resultObject.put("dataList", userArray);
		resultObject.put("totalPage", totalPage);
		resultObject.put("currentPage", pageIndex);
		resultObject.put("totalResult", totalResult);
		resultObject.put("limitResult", limitResult);
		return resultObject;
	}
	
	@Override
	public JSONObject getAllPrizeList(String ixsgId,Integer lottery) {
		// TODO Auto-generated method stub
		//获取抽奖条目
		JSONObject resultObject = new JSONObject();
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("lineKey", "ixsgId");
		hashMap.put("lineValue", ixsgId);
		YxLotterySchool lotterySchool = ixuestarCloudELMapper.getLotterySchool(hashMap);
		if (lotterySchool!=null) {
			String ylId = lotterySchool.getYlId();
			//获取今天日期
			String today = "";
			if (lottery==1) {
				today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());				
			}else if (lottery==-1) {
				int mondayPlus = DateUtil.getMondayPlus();
		        Calendar currentDate = Calendar.getInstance();
		        currentDate.add(Calendar.DATE, mondayPlus-1);
				today = new SimpleDateFormat("yyyy-MM-dd").format(currentDate.getTime());
			}
			hashMap.put("tDate", today);
			hashMap.put("ylId", ylId);
			JSONArray listArray = new JSONArray();
			List<YxuserLottery> allYxuserLotteries = ixuestarCloudELMapper.getAllYxuserLotteries(hashMap);
			for (int i = 0; i < allYxuserLotteries.size(); i++) {
				YxuserLottery yxuserLottery = allYxuserLotteries.get(i);
				//获取相关参数
				String ypId = yxuserLottery.getYpId();
				YxPrizeInfo prizeInfo = ixuestarCloudELMapper.getPrizeInfo(ypId);
				//获取相关学校信息
				String ywId = yxuserLottery.getYwId();
				hashMap.put("lineKey", "ywId");
				hashMap.put("lineValue", ywId);
				YxWxuser yxWxuser = ixuestarCloudELMapper.getYxWxuser(hashMap);
				if (yxWxuser!=null) {
					String ixssId = yxWxuser.getIxssId();
					//获取信息
					JSONObject schoolStudentInfo = getSchoolStudentInfo(ixssId);
					//添加
					JSONObject stuPrizeObject = new JSONObject();
					stuPrizeObject.put("stuInfo", schoolStudentInfo);
					stuPrizeObject.put("prizeInfo", prizeInfo);
					listArray.add(stuPrizeObject);
				}
			}
			resultObject.put("dataList", listArray);
			resultObject.put("dataListNum", listArray.size());
		}
		return resultObject;
	}
	
	@Override
	public JSONObject getClockinStatus(String ywOpenId) {
		// TODO Auto-generated method stub
		JSONObject jsonObject = new JSONObject();
		//获取签到对象
		Map<String, Object> hashMap = new HashMap<>();
		hashMap.put("ywaType0", 1);
		hashMap.put("ywaType1", 3);
		hashMap.put("ywId", ywOpenId);
		//今天的日期
		String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		hashMap.put("ywaPlayDate", today);
		List<YxWatchAds> watchAdsInfos = ixuestarCloudELMapper.getWatchAdsInfos(hashMap);
		if (watchAdsInfos.size()==0) {
			jsonObject.put("clockinStatus", 0);
		}else if (watchAdsInfos.size()==1) {
			jsonObject.put("clockinStatus", 1);
		}
		return jsonObject;
	}
}
